[libvirt] [PATCH] daemon: Don't try to free an unsigned int in error paths

Christophe Fergeau cfergeau at redhat.com
Fri Apr 22 17:04:14 UTC 2011


On Fri, Apr 22, 2011 at 10:55:04AM -0600, Eric Blake wrote:
> On 04/22/2011 10:31 AM, Christophe Fergeau wrote:
> > -# define VIR_FREE(ptr) virFree(&(ptr))
> > +# define VIR_FREE(ptr) \
> > +    do { void *check_type = (ptr); virFree(&(check_type)); } while (0)
> 
> Not quite.  That assigns check_type to NULL, rather than the intended
> assignment of ptr.

Ooops, indeed. Initially, I didn't change the parameter of virFree, but
got "unused variable 'check_type'" warnings from gcc, so I went this way.
Using ATTRIBUTE_UNUSED and not changing virFree parameter will indeed work
better ;)

> > I also get more warnings about casting from const to non-const, this can
> > be avoided by making check_type const void *, but maybe these warnings
> > indicate that something that shouldn't be freed is freed.
> 
> How many warnings?  If it's only a handful, we should start
> investigating; if it's lots, then I'm not sure how much it buys us.

I get 93 such warnings on a test build, I'll look at a few ones at random
and report if that shows real bugs.

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110422/1c35ceb5/attachment-0001.sig>


More information about the libvir-list mailing list