fdgrowtable() cleanup

Dag-Erling Smørgrav des at des.no
Wed Sep 19 16:52:04 UTC 2012


Konstantin Belousov <kostikbel at gmail.com> writes:
> "Dag-Erling Smørgrav" <des at des.no> writes:
> > +	otable = fdp->fd_ofiles;
> > +	ofileflags = fdp->fd_ofileflags;
> These two new calculations could be unused if the function return early.

I assume you mean assignments, not calculations.  I trust the compiler
to move them to where they are needed - a trivial optimization with SSA.

> > +	ntable = malloc(nnfiles * sizeof(*ntable) +
> > +	    nnfiles * sizeof(*nfileflags) +
> > +	    sizeof(struct freetable),
> >  	    M_FILEDESC, M_ZERO | M_WAITOK);
> Please use the horizontal space less lavishly.

I was aiming for readability, not compatibility with equipment that went
out of use before I was born.

> I think that this calculation, as well as fo calculation below, does
> not take a required alignment of struct freetable into consideration.

Correct, thanks for pointing it out.  The easiest solution is to place
the struct freetable between the file array and the flag array.

DES
-- 
Dag-Erling Smørgrav - des at des.no


More information about the freebsd-hackers mailing list