diff mbox

[v4,4/4] build: enable no-parentheses in clang

Message ID 20170214123057.92544-5-roger.pau@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Roger Pau Monné Feb. 14, 2017, 12:30 p.m. UTC
And fix the following errors reported:

traps.c:2014:25: error: equality comparison with extraneous parentheses
      [-Werror,-Wparentheses-equality]
        else if ( (port == RTC_PORT(0)) )
                   ~~~~~^~~~~~~~~~~~~~
traps.c:2014:25: note: remove extraneous parentheses around the comparison to silence this warning
        else if ( (port == RTC_PORT(0)) )
                  ~     ^             ~
traps.c:2014:25: note: use '=' to turn this equality comparison into an assignment
        else if ( (port == RTC_PORT(0)) )
                        ^~
                        =
traps.c:2083:25: error: equality comparison with extraneous parentheses
      [-Werror,-Wparentheses-equality]
        else if ( (port == RTC_PORT(0)) )
                   ~~~~~^~~~~~~~~~~~~~

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Tim Deegan <tim@xen.org>
Cc: Wei Liu <wei.liu2@citrix.com>
---
 Config.mk            | 3 ---
 xen/arch/x86/traps.c | 4 ++--
 2 files changed, 2 insertions(+), 5 deletions(-)

Comments

Andrew Cooper Feb. 14, 2017, 1:43 p.m. UTC | #1
On 14/02/17 12:30, Roger Pau Monne wrote:
> And fix the following errors reported:
>
> traps.c:2014:25: error: equality comparison with extraneous parentheses
>       [-Werror,-Wparentheses-equality]
>         else if ( (port == RTC_PORT(0)) )
>                    ~~~~~^~~~~~~~~~~~~~
> traps.c:2014:25: note: remove extraneous parentheses around the comparison to silence this warning
>         else if ( (port == RTC_PORT(0)) )
>                   ~     ^             ~
> traps.c:2014:25: note: use '=' to turn this equality comparison into an assignment
>         else if ( (port == RTC_PORT(0)) )
>                         ^~
>                         =
> traps.c:2083:25: error: equality comparison with extraneous parentheses
>       [-Werror,-Wparentheses-equality]
>         else if ( (port == RTC_PORT(0)) )
>                    ~~~~~^~~~~~~~~~~~~~
>
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> ---
> Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> Cc: George Dunlap <George.Dunlap@eu.citrix.com>
> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> Cc: Jan Beulich <jbeulich@suse.com>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Cc: Stefano Stabellini <sstabellini@kernel.org>
> Cc: Tim Deegan <tim@xen.org>
> Cc: Wei Liu <wei.liu2@citrix.com>

Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Jan Beulich Feb. 14, 2017, 1:56 p.m. UTC | #2
>>> On 14.02.17 at 13:30, <roger.pau@citrix.com> wrote:
> --- a/Config.mk
> +++ b/Config.mk
> @@ -212,9 +212,6 @@ CFLAGS += -std=gnu99
>  
>  CFLAGS += -Wall -Wstrict-prototypes
>  
> -# Clang complains about macros that expand to 'if ( ( foo == bar ) ) ...'
> -CFLAGS-$(clang) += -Wno-parentheses

Taking the comment being removed here together with ....

> --- a/xen/arch/x86/traps.c
> +++ b/xen/arch/x86/traps.c
> @@ -2011,7 +2011,7 @@ uint32_t guest_io_read(unsigned int port, unsigned int bytes,
>          {
>              sub_data = pv_pit_handler(port, 0, 0);
>          }
> -        else if ( (port == RTC_PORT(0)) )
> +        else if ( port == RTC_PORT(0) )
>          {
>              sub_data = currd->arch.cmos_idx;
>          }
> @@ -2080,7 +2080,7 @@ void guest_io_write(unsigned int port, unsigned int bytes, uint32_t data,
>          {
>              pv_pit_handler(port, (uint8_t)data, 1);
>          }
> -        else if ( (port == RTC_PORT(0)) )
> +        else if ( port == RTC_PORT(0) )
>          {
>              currd->arch.cmos_idx = data;
>          }

... the code adjustments all being to other than macros I wonder
whether in the version you use the issue is no longer being
reported in macro expansions, but older clang still chokes on such.
Or did you go check that we have no such uses left (which seems
unlikely to me)?

Jan
Roger Pau Monné Feb. 14, 2017, 2:06 p.m. UTC | #3
On Tue, Feb 14, 2017 at 06:56:12AM -0700, Jan Beulich wrote:
> >>> On 14.02.17 at 13:30, <roger.pau@citrix.com> wrote:
> > --- a/Config.mk
> > +++ b/Config.mk
> > @@ -212,9 +212,6 @@ CFLAGS += -std=gnu99
> >  
> >  CFLAGS += -Wall -Wstrict-prototypes
> >  
> > -# Clang complains about macros that expand to 'if ( ( foo == bar ) ) ...'
> > -CFLAGS-$(clang) += -Wno-parentheses
> 
> Taking the comment being removed here together with ....
> 
> > --- a/xen/arch/x86/traps.c
> > +++ b/xen/arch/x86/traps.c
> > @@ -2011,7 +2011,7 @@ uint32_t guest_io_read(unsigned int port, unsigned int bytes,
> >          {
> >              sub_data = pv_pit_handler(port, 0, 0);
> >          }
> > -        else if ( (port == RTC_PORT(0)) )
> > +        else if ( port == RTC_PORT(0) )
> >          {
> >              sub_data = currd->arch.cmos_idx;
> >          }
> > @@ -2080,7 +2080,7 @@ void guest_io_write(unsigned int port, unsigned int bytes, uint32_t data,
> >          {
> >              pv_pit_handler(port, (uint8_t)data, 1);
> >          }
> > -        else if ( (port == RTC_PORT(0)) )
> > +        else if ( port == RTC_PORT(0) )
> >          {
> >              currd->arch.cmos_idx = data;
> >          }
> 
> ... the code adjustments all being to other than macros I wonder
> whether in the version you use the issue is no longer being
> reported in macro expansions, but older clang still chokes on such.
> Or did you go check that we have no such uses left (which seems
> unlikely to me)?

I assume that in recent versions of clang this is no longer an issue. Travis
tests with clang 3.5 and I test with 3.8, and none of them find any issues.
IMHO we should turn it on because I barely doubt anyone is building Xen with
older versions of clang, when I started working on this the clang support was
completely bitrotted.

Roger.
Andrew Cooper Feb. 14, 2017, 2:13 p.m. UTC | #4
On 14/02/17 14:06, Roger Pau Monne wrote:
> On Tue, Feb 14, 2017 at 06:56:12AM -0700, Jan Beulich wrote:
>>>>> On 14.02.17 at 13:30, <roger.pau@citrix.com> wrote:
>>> --- a/Config.mk
>>> +++ b/Config.mk
>>> @@ -212,9 +212,6 @@ CFLAGS += -std=gnu99
>>>  
>>>  CFLAGS += -Wall -Wstrict-prototypes
>>>  
>>> -# Clang complains about macros that expand to 'if ( ( foo == bar ) ) ...'
>>> -CFLAGS-$(clang) += -Wno-parentheses
>> Taking the comment being removed here together with ....
>>
>>> --- a/xen/arch/x86/traps.c
>>> +++ b/xen/arch/x86/traps.c
>>> @@ -2011,7 +2011,7 @@ uint32_t guest_io_read(unsigned int port, unsigned int bytes,
>>>          {
>>>              sub_data = pv_pit_handler(port, 0, 0);
>>>          }
>>> -        else if ( (port == RTC_PORT(0)) )
>>> +        else if ( port == RTC_PORT(0) )
>>>          {
>>>              sub_data = currd->arch.cmos_idx;
>>>          }
>>> @@ -2080,7 +2080,7 @@ void guest_io_write(unsigned int port, unsigned int bytes, uint32_t data,
>>>          {
>>>              pv_pit_handler(port, (uint8_t)data, 1);
>>>          }
>>> -        else if ( (port == RTC_PORT(0)) )
>>> +        else if ( port == RTC_PORT(0) )
>>>          {
>>>              currd->arch.cmos_idx = data;
>>>          }
>> ... the code adjustments all being to other than macros I wonder
>> whether in the version you use the issue is no longer being
>> reported in macro expansions, but older clang still chokes on such.
>> Or did you go check that we have no such uses left (which seems
>> unlikely to me)?
> I assume that in recent versions of clang this is no longer an issue. Travis
> tests with clang 3.5 and I test with 3.8, and none of them find any issues.
> IMHO we should turn it on because I barely doubt anyone is building Xen with
> older versions of clang, when I started working on this the clang support was
> completely bitrotted.

There was some Clang 3.2 support in the past, but it had completely
bitrotten.

Clang 3.5 is our documented minimum, so I think it is reasonable to take
these clobbers out, seeing as they are not needed.

~Andrew
Jan Beulich Feb. 14, 2017, 2:21 p.m. UTC | #5
>>> On 14.02.17 at 15:13, <andrew.cooper3@citrix.com> wrote:
> On 14/02/17 14:06, Roger Pau Monne wrote:
>> On Tue, Feb 14, 2017 at 06:56:12AM -0700, Jan Beulich wrote:
>>>>>> On 14.02.17 at 13:30, <roger.pau@citrix.com> wrote:
>>>> --- a/Config.mk
>>>> +++ b/Config.mk
>>>> @@ -212,9 +212,6 @@ CFLAGS += -std=gnu99
>>>>  
>>>>  CFLAGS += -Wall -Wstrict-prototypes
>>>>  
>>>> -# Clang complains about macros that expand to 'if ( ( foo == bar ) ) ...'
>>>> -CFLAGS-$(clang) += -Wno-parentheses
>>> Taking the comment being removed here together with ....
>>>
>>>> --- a/xen/arch/x86/traps.c
>>>> +++ b/xen/arch/x86/traps.c
>>>> @@ -2011,7 +2011,7 @@ uint32_t guest_io_read(unsigned int port, unsigned int bytes,
>>>>          {
>>>>              sub_data = pv_pit_handler(port, 0, 0);
>>>>          }
>>>> -        else if ( (port == RTC_PORT(0)) )
>>>> +        else if ( port == RTC_PORT(0) )
>>>>          {
>>>>              sub_data = currd->arch.cmos_idx;
>>>>          }
>>>> @@ -2080,7 +2080,7 @@ void guest_io_write(unsigned int port, unsigned int bytes, uint32_t data,
>>>>          {
>>>>              pv_pit_handler(port, (uint8_t)data, 1);
>>>>          }
>>>> -        else if ( (port == RTC_PORT(0)) )
>>>> +        else if ( port == RTC_PORT(0) )
>>>>          {
>>>>              currd->arch.cmos_idx = data;
>>>>          }
>>> ... the code adjustments all being to other than macros I wonder
>>> whether in the version you use the issue is no longer being
>>> reported in macro expansions, but older clang still chokes on such.
>>> Or did you go check that we have no such uses left (which seems
>>> unlikely to me)?
>> I assume that in recent versions of clang this is no longer an issue. Travis
>> tests with clang 3.5 and I test with 3.8, and none of them find any issues.
>> IMHO we should turn it on because I barely doubt anyone is building Xen with
>> older versions of clang, when I started working on this the clang support was
>> completely bitrotted.
> 
> There was some Clang 3.2 support in the past, but it had completely
> bitrotten.
> 
> Clang 3.5 is our documented minimum, so I think it is reasonable to take
> these clobbers out, seeing as they are not needed.

Okay, if the minimum version was tested, then I'm fine with the
adjustment.

Jan
diff mbox

Patch

diff --git a/Config.mk b/Config.mk
index bff4dc5..9a28d15 100644
--- a/Config.mk
+++ b/Config.mk
@@ -212,9 +212,6 @@  CFLAGS += -std=gnu99
 
 CFLAGS += -Wall -Wstrict-prototypes
 
-# Clang complains about macros that expand to 'if ( ( foo == bar ) ) ...'
-CFLAGS-$(clang) += -Wno-parentheses
-
 $(call cc-option-add,HOSTCFLAGS,HOSTCC,-Wdeclaration-after-statement)
 $(call cc-option-add,CFLAGS,CC,-Wdeclaration-after-statement)
 $(call cc-option-add,CFLAGS,CC,-Wno-unused-but-set-variable)
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index 691c9a2..eb634d9 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -2011,7 +2011,7 @@  uint32_t guest_io_read(unsigned int port, unsigned int bytes,
         {
             sub_data = pv_pit_handler(port, 0, 0);
         }
-        else if ( (port == RTC_PORT(0)) )
+        else if ( port == RTC_PORT(0) )
         {
             sub_data = currd->arch.cmos_idx;
         }
@@ -2080,7 +2080,7 @@  void guest_io_write(unsigned int port, unsigned int bytes, uint32_t data,
         {
             pv_pit_handler(port, (uint8_t)data, 1);
         }
-        else if ( (port == RTC_PORT(0)) )
+        else if ( port == RTC_PORT(0) )
         {
             currd->arch.cmos_idx = data;
         }