On Wed, Sep 19, 2012 at 02:58:02PM +0200, Dag-Erling Sm??rgrav wrote: > Konstantin Belousov <kostik...@gmail.com> writes: > > "Dag-Erling Sm??rgrav" <d...@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.
pgpA1ORGQL5xf.pgp
Description: PGP signature