From owner-svn-src-all@FreeBSD.ORG Mon Sep 24 09:14:30 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id BFDCD106564A; Mon, 24 Sep 2012 09:14:30 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 3053B8FC12; Mon, 24 Sep 2012 09:14:29 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q8O9EY7s096629; Mon, 24 Sep 2012 12:14:35 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q8O9EM1Q033406; Mon, 24 Sep 2012 12:14:22 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q8O9EM4I033405; Mon, 24 Sep 2012 12:14:22 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 24 Sep 2012 12:14:22 +0300 From: Konstantin Belousov To: David Chisnall Message-ID: <20120924091422.GS37286@deviant.kiev.zoral.com.ua> References: <201209230838.q8N8c6Tu056083@svn.freebsd.org> <20120923105220.GL37286@deviant.kiev.zoral.com.ua> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="YW0vl6bOwYQ/J4Ih" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: Garrett Cooper , Kevin Lo , svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r240850 - head/lib/libstand X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Sep 2012 09:14:30 -0000 --YW0vl6bOwYQ/J4Ih Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Sep 24, 2012 at 09:47:45AM +0100, David Chisnall wrote: > On 23 Sep 2012, at 20:27, Garrett Cooper wrote: >=20 > > +1. free(3) should silently ignore NULL parameters passed into it. >=20 > Indeed. The C standard's description for free() states that: >=20 > > If ptr is a null pointer, no action occurs. >=20 > This means that a standards-compilant compiler is entirely at liberty > to elide these checks (not sure if GCC or LLVM does, but both have > optimisation passes that optimise based on assumptions about standard > library functions, although they may not run when compiled in a > freestanding environment). > In this specific case your note is irrelevant, since libstand free() is not a function at all. Would you look at the code, you note that free() is the macro calling the function Free(). Indeed, in freestanding environment conforming compiler is denied to specially process free(). > The only reasons for a NULL check before free() should be: >=20 > - Sanity checking (i.e. this pointer is never meant to be NULL, assert th= at it isnt) > - Recursive cleanup (don't dereference this pointer to clean up its eleme= nts if it is NULL) - Non-standard free() which does not understand NULL. >=20 > David --YW0vl6bOwYQ/J4Ih Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAlBgJG0ACgkQC3+MBN1Mb4jbwQCgrv1rUCY+COF/nrIAGNuweSEv BD4An0z/1vIFAuMaJJvOLWihXaha3cp5 =2CyZ -----END PGP SIGNATURE----- --YW0vl6bOwYQ/J4Ih--