fdgrowtable() cleanup

Konstantin Belousov kostikbel at gmail.com
Wed Sep 19 17:54:01 UTC 2012


On Wed, Sep 19, 2012 at 02:58:02PM +0200, Dag-Erling Sm??rgrav wrote:
> 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.
It is a dereference before the assignment, so I perceive it as the
calculation. No, I do not think that compiler can move the dereference,
because there are many sequential points between the calculation and
use of the result.

> 
> > > +	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.
Well, my eyes can only see so many lines in the emacs window. So if you
referenced older equipment meaning me being born before you, so be it.
:)

> 
> > 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.

As I know, for all ABIs FreeBSD run on, the structure alignment is the
alignment of the most requiring member. You would introduce very tacit
dependency between struct file and struct freetable.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20120919/3f02c5fb/attachment.pgp


More information about the freebsd-hackers mailing list