From owner-freebsd-hackers@FreeBSD.ORG Wed Sep 19 16:52:04 2012 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C6D9B106566C for ; Wed, 19 Sep 2012 16:52:04 +0000 (UTC) (envelope-from des@des.no) Received: from smtp.des.no (smtp.des.no [194.63.250.102]) by mx1.freebsd.org (Postfix) with ESMTP id 870588FC1A for ; Wed, 19 Sep 2012 16:52:03 +0000 (UTC) Received: from ds4.des.no (smtp.des.no [194.63.250.102]) by smtp.des.no (Postfix) with ESMTP id 088A56FD8; Wed, 19 Sep 2012 18:51:57 +0200 (CEST) Received: by ds4.des.no (Postfix, from userid 1001) id C067385EE; Wed, 19 Sep 2012 14:58:03 +0200 (CEST) From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= To: Konstantin Belousov References: <86wqzr8hbk.fsf@ds4.des.no> <20120919061005.GR37286@deviant.kiev.zoral.com.ua> Date: Wed, 19 Sep 2012 14:58:02 +0200 In-Reply-To: <20120919061005.GR37286@deviant.kiev.zoral.com.ua> (Konstantin Belousov's message of "Wed, 19 Sep 2012 09:10:05 +0300") Message-ID: <86lig6map1.fsf@ds4.des.no> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: hackers@freebsd.org Subject: Re: fdgrowtable() cleanup X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Sep 2012 16:52:04 -0000 Konstantin Belousov writes: > "Dag-Erling Sm=C3=B8rgrav" 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