Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Sep 2012 14:58:02 +0200
From:      =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@des.no>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        hackers@freebsd.org
Subject:   Re: fdgrowtable() cleanup
Message-ID:  <86lig6map1.fsf@ds4.des.no>
In-Reply-To: <20120919061005.GR37286@deviant.kiev.zoral.com.ua> (Konstantin Belousov's message of "Wed, 19 Sep 2012 09:10:05 %2B0300")
References:  <86wqzr8hbk.fsf@ds4.des.no> <20120919061005.GR37286@deviant.kiev.zoral.com.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
Konstantin Belousov <kostikbel@gmail.com> writes:
> "Dag-Erling Sm=C3=B8rgrav" <des@des.no> writes:
> > +	otable =3D fdp->fd_ofiles;
> > +	ofileflags =3D 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 =3D 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
--=20
Dag-Erling Sm=C3=B8rgrav - des@des.no



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86lig6map1.fsf>