On 08/26/2015 06:02 AM, Markus Armbruster wrote: > "Daniel P. Berrange" <berra...@redhat.com> writes: > >> The free() and g_free() functions both happily accept >> NULL on any platform QEMU builds on. > > Do systems where free(NULL) doesn't work even exist? Even C89 > guarantees it does nothing.
Solaris 4 was the last (pre-C89) system I am aware of that didn't like free(NULL). Ancient history nowadays. > > My Coccinelle semantic patch finds a few more, because it also fixes up > the equally pointless conditional > > if (foo) { > free(foo); > foo = NULL; > } The assignment to foo is not pointless, but removing the conditional is indeed nice. gnulib's perl script is a lot weaker than coccinelle, obviously :) > > @@ > expression E; > @@ > - if (E != NULL) { > - g_free(E); > - E = NULL; > - } > + g_free(E); > + E = NULL; This only checks for g_free() before assignment to NULL; are there any uses of raw free() that do the same? > Result (feel free to squash it into your patch): > Whether squashed in or separate, these additional changes and the original patch are: Reviewed-by: Eric Blake <ebl...@redhat.com> -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature