Date: Mon, 24 Sep 2012 12:14:22 +0300 From: Konstantin Belousov <kostikbel@gmail.com> To: David Chisnall <theraven@freebsd.org> Cc: Garrett Cooper <yanegomi@gmail.com>, Kevin Lo <kevlo@freebsd.org>, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r240850 - head/lib/libstand Message-ID: <20120924091422.GS37286@deviant.kiev.zoral.com.ua> In-Reply-To: <E7AE8382-853A-41D9-981C-0C6A09785A53@FreeBSD.org> References: <201209230838.q8N8c6Tu056083@svn.freebsd.org> <20120923105220.GL37286@deviant.kiev.zoral.com.ua> <CAGH67wQf5whjgQmXD3Ln_-r=WsLMYrBQUBj_G-HoGf1a5F_4cg@mail.gmail.com> <E7AE8382-853A-41D9-981C-0C6A09785A53@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --] On Mon, Sep 24, 2012 at 09:47:45AM +0100, David Chisnall wrote: > On 23 Sep 2012, at 20:27, Garrett Cooper wrote: > > > +1. free(3) should silently ignore NULL parameters passed into it. > > Indeed. The C standard's description for free() states that: > > > If ptr is a null pointer, no action occurs. > > 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: > > - Sanity checking (i.e. this pointer is never meant to be NULL, assert that it isnt) > - Recursive cleanup (don't dereference this pointer to clean up its elements if it is NULL) - Non-standard free() which does not understand NULL. > > David [-- Attachment #2 --] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAlBgJG0ACgkQC3+MBN1Mb4jbwQCgrv1rUCY+COF/nrIAGNuweSEv BD4An0z/1vIFAuMaJJvOLWihXaha3cp5 =2CyZ -----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120924091422.GS37286>
