Date: Wed, 19 Sep 2012 20:53:54 +0300 From: Konstantin Belousov <kostikbel@gmail.com> To: Dag-Erling Sm??rgrav <des@des.no> Cc: hackers@freebsd.org Subject: Re: fdgrowtable() cleanup Message-ID: <20120919175354.GV37286@deviant.kiev.zoral.com.ua> In-Reply-To: <86lig6map1.fsf@ds4.des.no> References: <86wqzr8hbk.fsf@ds4.des.no> <20120919061005.GR37286@deviant.kiev.zoral.com.ua> <86lig6map1.fsf@ds4.des.no>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --] On Wed, Sep 19, 2012 at 02:58:02PM +0200, Dag-Erling Sm??rgrav wrote: > Konstantin Belousov <kostikbel@gmail.com> writes: > > "Dag-Erling Sm??rgrav" <des@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. [-- Attachment #2 --] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAlBaBrIACgkQC3+MBN1Mb4hjtgCgmNUya61J4VWgGSllJn1dbHeL KT0An2hj2M6XWopB1+Ak/w6eDtAz76mE =rNl1 -----END PGP SIGNATURE-----help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120919175354.GV37286>
