[libvirt] [PATCH] util: warn when passing a non-pointer to VIR_FREE

Christophe Fergeau cfergeau at redhat.com
Tue Apr 26 20:03:16 UTC 2011


Hey,

On Fri, Apr 22, 2011 at 05:36:25PM -0600, Eric Blake wrote:
> That evaluates ptr twice.  We can do better, by exploiting that the
> ternary operator can be used to determine the type of an expression
> without evaluating it.  Gcc allows 1?(void*)expr:pointer (the resulting
> type is void*), but hates 1?(void*)expr:int (promoting to int provokes a
> warning):
> 
> cc1: warnings being treated as errors
> remote.c: In function 'remoteDispatchListNetworks':
> remote.c:3684:70: error: pointer/integer type mismatch in conditional
> expression
> 
> So how about:

Sorry for the late answer, but this looks good to me too. Let's hope gcc
doesn't get too clever and never stops warning about this.

Thanks,

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/20110426/314cbf8e/attachment-0001.sig>


More information about the libvir-list mailing list