From: Juergen Gross <juergen.gross@ts.fujitsu.com>
To: Ian Campbell <Ian.Campbell@citrix.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Ian Jackson <Ian.Jackson@eu.citrix.com>,
Jan Beulich <JBeulich@suse.com>,
xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH] libxc/pm: Fix NULL pointer checks.
Date: Tue, 10 Sep 2013 15:03:49 +0200 [thread overview]
Message-ID: <522F18B5.6030402@ts.fujitsu.com> (raw)
In-Reply-To: <1378817307.21748.110.camel@kazak.uk.xensource.com>
On 10.09.2013 14:48, Ian Campbell wrote:
> On Tue, 2013-09-10 at 13:23 +0100, Jan Beulich wrote:
>>>>> On 10.09.13 at 11:29, Andrew Cooper <andrew.cooper3@citrix.com> 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;
> }
-Wextra is needed to produce an error:
http://gcc.gnu.org/onlinedocs/gcc-4.7.3/gcc/Warning-Options.html#Warning-Options
Juergen
--
Juergen Gross Principal Developer Operating Systems
PBG PDG ES&S SWE OS6 Telephone: +49 (0) 89 3222 2967
Fujitsu Technology Solutions e-mail: juergen.gross@ts.fujitsu.com
Domagkstr. 28 Internet: ts.fujitsu.com
D-80807 Muenchen Company details: ts.fujitsu.com/imprint.html
next prev parent reply other threads:[~2013-09-10 13:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-10 9:29 [PATCH] libxc/pm: Fix NULL pointer checks Andrew Cooper
2013-09-10 10:55 ` Ian Campbell
2013-09-10 12:23 ` Jan Beulich
2013-09-10 12:48 ` Ian Campbell
2013-09-10 13:03 ` Juergen Gross [this message]
2013-09-10 13:24 ` Jan Beulich
2013-09-10 15:02 ` Ian Jackson
2013-09-10 15:10 ` Ian Jackson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=522F18B5.6030402@ts.fujitsu.com \
--to=juergen.gross@ts.fujitsu.com \
--cc=Ian.Campbell@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.