[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] libxc/pm: Fix NULL pointer checks.



>>> On 10.09.13 at 14:48, Ian Campbell <Ian.Campbell@xxxxxxxxxx> wrote:
> On Tue, 2013-09-10 at 13:23 +0100, Jan Beulich wrote:
>> >>> On 10.09.13 at 11:29, Andrew Cooper <andrew.cooper3@xxxxxxxxxx> wrote:
>> > --- a/tools/libxc/xc_pm.c
>> > +++ b/tools/libxc/xc_pm.c
>> > @@ -285,7 +285,7 @@ int xc_set_cpufreq_gov(xc_interface *xch, int cpuid, 
> char *govname)
>> >      DECLARE_SYSCTL;
>> >      char *scaling_governor = sysctl.u.pm_op.u.set_gov.scaling_governor;
>> >  
>> > -    if ( (xch < 0) || (!govname) )
>> > +    if ( !xch || !govname )
>> 
>> I'm very surprised the compiler didn't reject this - I'm unaware of
>> an extension that would allow pointers to be compared by other
>> than == and != (plus it's all but clear what e.g. a "negative"
>> pointer really is).
> 
> We were just discussing this at lunch and couldn't work it out either,
> but indeed both gcc 4.7.[23] and clang 3.2 accept this when building
> with -Wall:
> int main(int argc, char **argv)
> {
>       if ( argv[1] < 0 )
>               printf("ARGV[1] < 0\n");
>       else
>               printf("ARGV[1] >= 0\n");
>       return 0;
> }

Right. The warning is hidden behind -Wextra (i.e. there's no
more specific flag controlling this), and there's no way to turn off
that behavior altogether. Odd, but I guess we have to live with
it (entering this as a bug would just produce another of the many
orphaned entries in their bugzilla I'm afraid).

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.