All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [Bug 1651167] [NEW] hw/ipmi/isa_ipmi_bt.c:283: suspect use of macro ?
@ 2016-12-19 15:47 dcb
  2016-12-22 14:20 ` Corey Minyard
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: dcb @ 2016-12-19 15:47 UTC (permalink / raw)
  To: qemu-devel

Public bug reported:

I just had a go at compiling qemu trunk with
llvm trunk. It said:

hw/ipmi/isa_ipmi_bt.c:283:31: warning: logical not is only applied to
the left hand side of this bitwise operator [-Wlogical-not-parentheses]

Source code is

           IPMI_BT_SET_HBUSY(ib->control_reg,
                              !IPMI_BT_GET_HBUSY(ib->control_reg));

That use of ! causes trouble. The SET and GET
macros are defined as:

#define IPMI_BT_GET_HBUSY(d)       (((d) >> IPMI_BT_HBUSY_BIT) & 0x1)
#define IPMI_BT_SET_HBUSY(d, v)    (d) = (((d) & ~IPMI_BT_HBUSY_MASK) | \
                                       (((v & 1) << IPMI_BT_HBUSY_BIT)))

I can make the compiler shut up by adding extra () in the last
use of v in the SET macro, like this:

#define IPMI_BT_SET_HBUSY(d, v)    (d) = (((d) & ~IPMI_BT_HBUSY_MASK) | \
                                       ((((v) & 1) << IPMI_BT_HBUSY_BIT)))

I think this is standard good practice when using macro parameters
anyway.

** Affects: qemu
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1651167

Title:
  hw/ipmi/isa_ipmi_bt.c:283: suspect use of macro ?

Status in QEMU:
  New

Bug description:
  I just had a go at compiling qemu trunk with
  llvm trunk. It said:

  hw/ipmi/isa_ipmi_bt.c:283:31: warning: logical not is only applied to
  the left hand side of this bitwise operator [-Wlogical-not-
  parentheses]

  Source code is

             IPMI_BT_SET_HBUSY(ib->control_reg,
                                !IPMI_BT_GET_HBUSY(ib->control_reg));

  That use of ! causes trouble. The SET and GET
  macros are defined as:

  #define IPMI_BT_GET_HBUSY(d)       (((d) >> IPMI_BT_HBUSY_BIT) & 0x1)
  #define IPMI_BT_SET_HBUSY(d, v)    (d) = (((d) & ~IPMI_BT_HBUSY_MASK) | \
                                         (((v & 1) << IPMI_BT_HBUSY_BIT)))

  I can make the compiler shut up by adding extra () in the last
  use of v in the SET macro, like this:

  #define IPMI_BT_SET_HBUSY(d, v)    (d) = (((d) & ~IPMI_BT_HBUSY_MASK) | \
                                         ((((v) & 1) << IPMI_BT_HBUSY_BIT)))

  I think this is standard good practice when using macro parameters
  anyway.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1651167/+subscriptions

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [Bug 1651167] [NEW] hw/ipmi/isa_ipmi_bt.c:283: suspect use of macro ?
  2016-12-19 15:47 [Qemu-devel] [Bug 1651167] [NEW] hw/ipmi/isa_ipmi_bt.c:283: suspect use of macro ? dcb
@ 2016-12-22 14:20 ` Corey Minyard
  2016-12-22 14:25 ` [Qemu-devel] [Bug 1651167] " cminyard
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Corey Minyard @ 2016-12-22 14:20 UTC (permalink / raw)
  To: Bug 1651167, qemu-devel

On 12/19/2016 09:47 AM, dcb wrote:
> Public bug reported:
>
> I just had a go at compiling qemu trunk with
> llvm trunk. It said:
>
> hw/ipmi/isa_ipmi_bt.c:283:31: warning: logical not is only applied to
> the left hand side of this bitwise operator [-Wlogical-not-parentheses]
>
> Source code is
>
>             IPMI_BT_SET_HBUSY(ib->control_reg,
>                                !IPMI_BT_GET_HBUSY(ib->control_reg));
>
> That use of ! causes trouble. The SET and GET
> macros are defined as:
>
> #define IPMI_BT_GET_HBUSY(d)       (((d) >> IPMI_BT_HBUSY_BIT) & 0x1)
> #define IPMI_BT_SET_HBUSY(d, v)    (d) = (((d) & ~IPMI_BT_HBUSY_MASK) | \
>                                         (((v & 1) << IPMI_BT_HBUSY_BIT)))
>
> I can make the compiler shut up by adding extra () in the last
> use of v in the SET macro, like this:
>
> #define IPMI_BT_SET_HBUSY(d, v)    (d) = (((d) & ~IPMI_BT_HBUSY_MASK) | \
>                                         ((((v) & 1) << IPMI_BT_HBUSY_BIT)))
>
> I think this is standard good practice when using macro parameters
> anyway.

Yeah, that's the way things are supposed to be done.  I'll get a patch 
out on this.
There were a bunch of them.

Thanks,

-corey

>
> ** Affects: qemu
>       Importance: Undecided
>           Status: New
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Qemu-devel] [Bug 1651167] Re: hw/ipmi/isa_ipmi_bt.c:283: suspect use of macro ?
  2016-12-19 15:47 [Qemu-devel] [Bug 1651167] [NEW] hw/ipmi/isa_ipmi_bt.c:283: suspect use of macro ? dcb
  2016-12-22 14:20 ` Corey Minyard
@ 2016-12-22 14:25 ` cminyard
  2016-12-22 14:30 ` [Qemu-devel] [PATCH] ipmi: Add parenthesis around some macro parameters minyard
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: cminyard @ 2016-12-22 14:25 UTC (permalink / raw)
  To: qemu-devel

** Changed in: qemu
     Assignee: (unassigned) => cminyard (minyard)

** Changed in: qemu
       Status: New => In Progress

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1651167

Title:
  hw/ipmi/isa_ipmi_bt.c:283: suspect use of macro ?

Status in QEMU:
  In Progress

Bug description:
  I just had a go at compiling qemu trunk with
  llvm trunk. It said:

  hw/ipmi/isa_ipmi_bt.c:283:31: warning: logical not is only applied to
  the left hand side of this bitwise operator [-Wlogical-not-
  parentheses]

  Source code is

             IPMI_BT_SET_HBUSY(ib->control_reg,
                                !IPMI_BT_GET_HBUSY(ib->control_reg));

  That use of ! causes trouble. The SET and GET
  macros are defined as:

  #define IPMI_BT_GET_HBUSY(d)       (((d) >> IPMI_BT_HBUSY_BIT) & 0x1)
  #define IPMI_BT_SET_HBUSY(d, v)    (d) = (((d) & ~IPMI_BT_HBUSY_MASK) | \
                                         (((v & 1) << IPMI_BT_HBUSY_BIT)))

  I can make the compiler shut up by adding extra () in the last
  use of v in the SET macro, like this:

  #define IPMI_BT_SET_HBUSY(d, v)    (d) = (((d) & ~IPMI_BT_HBUSY_MASK) | \
                                         ((((v) & 1) << IPMI_BT_HBUSY_BIT)))

  I think this is standard good practice when using macro parameters
  anyway.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1651167/+subscriptions

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PATCH] ipmi: Add parenthesis around some macro parameters
  2016-12-19 15:47 [Qemu-devel] [Bug 1651167] [NEW] hw/ipmi/isa_ipmi_bt.c:283: suspect use of macro ? dcb
  2016-12-22 14:20 ` Corey Minyard
  2016-12-22 14:25 ` [Qemu-devel] [Bug 1651167] " cminyard
@ 2016-12-22 14:30 ` minyard
  2016-12-22 15:01   ` Eric Blake
  2016-12-22 19:18 ` [Qemu-devel] [PATCH v2] ipmi: Fix macro issues minyard
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: minyard @ 2016-12-22 14:30 UTC (permalink / raw)
  To: Bug 1651167, qemu-devel; +Cc: Corey Minyard

From: Corey Minyard <cminyard@mvista.com>

Macro parameters should almost always have () around them when used.
llvm reported an error on this.

Reported in https://bugs.launchpad.net/bugs/1651167

Signed-off-by: Corey Minyard <cminyard@mvista.com>
---
 hw/ipmi/isa_ipmi_bt.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/hw/ipmi/isa_ipmi_bt.c b/hw/ipmi/isa_ipmi_bt.c
index f036617..8a97314 100644
--- a/hw/ipmi/isa_ipmi_bt.c
+++ b/hw/ipmi/isa_ipmi_bt.c
@@ -40,37 +40,37 @@
 #define IPMI_BT_CLR_WR_MASK        (1 << IPMI_BT_CLR_WR_BIT)
 #define IPMI_BT_GET_CLR_WR(d)      (((d) >> IPMI_BT_CLR_WR_BIT) & 0x1)
 #define IPMI_BT_SET_CLR_WR(d, v)   (d) = (((d) & ~IPMI_BT_CLR_WR_MASK) | \
-                                       (((v & 1) << IPMI_BT_CLR_WR_BIT)))
+                                       ((((v) & 1) << IPMI_BT_CLR_WR_BIT)))
 
 #define IPMI_BT_CLR_RD_MASK        (1 << IPMI_BT_CLR_RD_BIT)
 #define IPMI_BT_GET_CLR_RD(d)      (((d) >> IPMI_BT_CLR_RD_BIT) & 0x1)
 #define IPMI_BT_SET_CLR_RD(d, v)   (d) = (((d) & ~IPMI_BT_CLR_RD_MASK) | \
-                                       (((v & 1) << IPMI_BT_CLR_RD_BIT)))
+                                       ((((v) & 1) << IPMI_BT_CLR_RD_BIT)))
 
 #define IPMI_BT_H2B_ATN_MASK       (1 << IPMI_BT_H2B_ATN_BIT)
 #define IPMI_BT_GET_H2B_ATN(d)     (((d) >> IPMI_BT_H2B_ATN_BIT) & 0x1)
 #define IPMI_BT_SET_H2B_ATN(d, v)  (d) = (((d) & ~IPMI_BT_H2B_ATN_MASK) | \
-                                        (((v & 1) << IPMI_BT_H2B_ATN_BIT)))
+                                        ((((v) & 1) << IPMI_BT_H2B_ATN_BIT)))
 
 #define IPMI_BT_B2H_ATN_MASK       (1 << IPMI_BT_B2H_ATN_BIT)
 #define IPMI_BT_GET_B2H_ATN(d)     (((d) >> IPMI_BT_B2H_ATN_BIT) & 0x1)
 #define IPMI_BT_SET_B2H_ATN(d, v)  (d) = (((d) & ~IPMI_BT_B2H_ATN_MASK) | \
-                                        (((v & 1) << IPMI_BT_B2H_ATN_BIT)))
+                                        ((((v) & 1) << IPMI_BT_B2H_ATN_BIT)))
 
 #define IPMI_BT_SMS_ATN_MASK       (1 << IPMI_BT_SMS_ATN_BIT)
 #define IPMI_BT_GET_SMS_ATN(d)     (((d) >> IPMI_BT_SMS_ATN_BIT) & 0x1)
 #define IPMI_BT_SET_SMS_ATN(d, v)  (d) = (((d) & ~IPMI_BT_SMS_ATN_MASK) | \
-                                        (((v & 1) << IPMI_BT_SMS_ATN_BIT)))
+                                        ((((v) & 1) << IPMI_BT_SMS_ATN_BIT)))
 
 #define IPMI_BT_HBUSY_MASK         (1 << IPMI_BT_HBUSY_BIT)
 #define IPMI_BT_GET_HBUSY(d)       (((d) >> IPMI_BT_HBUSY_BIT) & 0x1)
 #define IPMI_BT_SET_HBUSY(d, v)    (d) = (((d) & ~IPMI_BT_HBUSY_MASK) | \
-                                       (((v & 1) << IPMI_BT_HBUSY_BIT)))
+                                       ((((v) & 1) << IPMI_BT_HBUSY_BIT)))
 
 #define IPMI_BT_BBUSY_MASK         (1 << IPMI_BT_BBUSY_BIT)
 #define IPMI_BT_GET_BBUSY(d)       (((d) >> IPMI_BT_BBUSY_BIT) & 0x1)
 #define IPMI_BT_SET_BBUSY(d, v)    (d) = (((d) & ~IPMI_BT_BBUSY_MASK) | \
-                                       (((v & 1) << IPMI_BT_BBUSY_BIT)))
+                                       ((((v) & 1) << IPMI_BT_BBUSY_BIT)))
 
 
 /* Mask register */
@@ -80,12 +80,12 @@
 #define IPMI_BT_B2H_IRQ_EN_MASK      (1 << IPMI_BT_B2H_IRQ_EN_BIT)
 #define IPMI_BT_GET_B2H_IRQ_EN(d)    (((d) >> IPMI_BT_B2H_IRQ_EN_BIT) & 0x1)
 #define IPMI_BT_SET_B2H_IRQ_EN(d, v) (d) = (((d) & ~IPMI_BT_B2H_IRQ_EN_MASK) | \
-                                        (((v & 1) << IPMI_BT_B2H_IRQ_EN_BIT)))
+                                        ((((v) & 1) << IPMI_BT_B2H_IRQ_EN_BIT)))
 
 #define IPMI_BT_B2H_IRQ_MASK         (1 << IPMI_BT_B2H_IRQ_BIT)
 #define IPMI_BT_GET_B2H_IRQ(d)       (((d) >> IPMI_BT_B2H_IRQ_BIT) & 0x1)
 #define IPMI_BT_SET_B2H_IRQ(d, v)    (d) = (((d) & ~IPMI_BT_B2H_IRQ_MASK) | \
-                                        (((v & 1) << IPMI_BT_B2H_IRQ_BIT)))
+                                        ((((v) & 1) << IPMI_BT_B2H_IRQ_BIT)))
 
 typedef struct IPMIBT {
     IPMIBmc *bmc;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH] ipmi: Add parenthesis around some macro parameters
  2016-12-22 14:30 ` [Qemu-devel] [PATCH] ipmi: Add parenthesis around some macro parameters minyard
@ 2016-12-22 15:01   ` Eric Blake
  2016-12-22 17:48     ` Corey Minyard
  0 siblings, 1 reply; 11+ messages in thread
From: Eric Blake @ 2016-12-22 15:01 UTC (permalink / raw)
  To: minyard, Bug 1651167, qemu-devel; +Cc: Corey Minyard

[-- Attachment #1: Type: text/plain, Size: 1816 bytes --]

On 12/22/2016 08:30 AM, minyard@acm.org wrote:
> From: Corey Minyard <cminyard@mvista.com>
> 
> Macro parameters should almost always have () around them when used.
> llvm reported an error on this.
> 
> Reported in https://bugs.launchpad.net/bugs/1651167
> 
> Signed-off-by: Corey Minyard <cminyard@mvista.com>
> ---
>  hw/ipmi/isa_ipmi_bt.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/hw/ipmi/isa_ipmi_bt.c b/hw/ipmi/isa_ipmi_bt.c
> index f036617..8a97314 100644
> --- a/hw/ipmi/isa_ipmi_bt.c
> +++ b/hw/ipmi/isa_ipmi_bt.c
> @@ -40,37 +40,37 @@
>  #define IPMI_BT_CLR_WR_MASK        (1 << IPMI_BT_CLR_WR_BIT)
>  #define IPMI_BT_GET_CLR_WR(d)      (((d) >> IPMI_BT_CLR_WR_BIT) & 0x1)
>  #define IPMI_BT_SET_CLR_WR(d, v)   (d) = (((d) & ~IPMI_BT_CLR_WR_MASK) | \

Still under-parenthesized, if the result of IPMI_BT_SET_CLR_WR() is used
in any larger expression;

> -                                       (((v & 1) << IPMI_BT_CLR_WR_BIT)))
> +                                       ((((v) & 1) << IPMI_BT_CLR_WR_BIT)))

and at the same time, you (still) have a redundant set on the second line.

Better would be:

((d) = (((d) & ~IPMI_BD_CLR_WR_MASK) | \
        (((v) & 1) << IPMI_BT_CLR_WR_BIT)))

>  
>  #define IPMI_BT_CLR_RD_MASK        (1 << IPMI_BT_CLR_RD_BIT)
>  #define IPMI_BT_GET_CLR_RD(d)      (((d) >> IPMI_BT_CLR_RD_BIT) & 0x1)
>  #define IPMI_BT_SET_CLR_RD(d, v)   (d) = (((d) & ~IPMI_BT_CLR_RD_MASK) | \
> -                                       (((v & 1) << IPMI_BT_CLR_RD_BIT)))
> +                                       ((((v) & 1) << IPMI_BT_CLR_RD_BIT)))

and again, throughout the patch.


-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH] ipmi: Add parenthesis around some macro parameters
  2016-12-22 15:01   ` Eric Blake
@ 2016-12-22 17:48     ` Corey Minyard
  0 siblings, 0 replies; 11+ messages in thread
From: Corey Minyard @ 2016-12-22 17:48 UTC (permalink / raw)
  To: Eric Blake, Bug 1651167, qemu-devel; +Cc: Corey Minyard

On 12/22/2016 09:01 AM, Eric Blake wrote:
> On 12/22/2016 08:30 AM, minyard@acm.org wrote:
>> From: Corey Minyard <cminyard@mvista.com>
>>
>> Macro parameters should almost always have () around them when used.
>> llvm reported an error on this.
>>
>> Reported in https://bugs.launchpad.net/bugs/1651167
>>
>> Signed-off-by: Corey Minyard <cminyard@mvista.com>
>> ---
>>   hw/ipmi/isa_ipmi_bt.c | 18 +++++++++---------
>>   1 file changed, 9 insertions(+), 9 deletions(-)
>>
>> diff --git a/hw/ipmi/isa_ipmi_bt.c b/hw/ipmi/isa_ipmi_bt.c
>> index f036617..8a97314 100644
>> --- a/hw/ipmi/isa_ipmi_bt.c
>> +++ b/hw/ipmi/isa_ipmi_bt.c
>> @@ -40,37 +40,37 @@
>>   #define IPMI_BT_CLR_WR_MASK        (1 << IPMI_BT_CLR_WR_BIT)
>>   #define IPMI_BT_GET_CLR_WR(d)      (((d) >> IPMI_BT_CLR_WR_BIT) & 0x1)
>>   #define IPMI_BT_SET_CLR_WR(d, v)   (d) = (((d) & ~IPMI_BT_CLR_WR_MASK) | \
> Still under-parenthesized, if the result of IPMI_BT_SET_CLR_WR() is used
> in any larger expression;

I wasn't thinking about this being used in a larger expression, but it 
should be protected,
I suppose.  I'll re-submit with that fixed and the extra () removed.

Thanks,

-corey

>> -                                       (((v & 1) << IPMI_BT_CLR_WR_BIT)))
>> +                                       ((((v) & 1) << IPMI_BT_CLR_WR_BIT)))
> and at the same time, you (still) have a redundant set on the second line.
>
> Better would be:
>
> ((d) = (((d) & ~IPMI_BD_CLR_WR_MASK) | \
>          (((v) & 1) << IPMI_BT_CLR_WR_BIT)))
>
>>   
>>   #define IPMI_BT_CLR_RD_MASK        (1 << IPMI_BT_CLR_RD_BIT)
>>   #define IPMI_BT_GET_CLR_RD(d)      (((d) >> IPMI_BT_CLR_RD_BIT) & 0x1)
>>   #define IPMI_BT_SET_CLR_RD(d, v)   (d) = (((d) & ~IPMI_BT_CLR_RD_MASK) | \
>> -                                       (((v & 1) << IPMI_BT_CLR_RD_BIT)))
>> +                                       ((((v) & 1) << IPMI_BT_CLR_RD_BIT)))
> and again, throughout the patch.
>
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PATCH v2] ipmi: Fix macro issues
  2016-12-19 15:47 [Qemu-devel] [Bug 1651167] [NEW] hw/ipmi/isa_ipmi_bt.c:283: suspect use of macro ? dcb
                   ` (2 preceding siblings ...)
  2016-12-22 14:30 ` [Qemu-devel] [PATCH] ipmi: Add parenthesis around some macro parameters minyard
@ 2016-12-22 19:18 ` minyard
  2016-12-22 22:17   ` Eric Blake
  2016-12-23 14:07 ` [Qemu-devel] [PATCH v3] " minyard
  2017-04-24  7:38 ` [Qemu-devel] [Bug 1651167] Re: hw/ipmi/isa_ipmi_bt.c:283: suspect use of macro ? Thomas Huth
  5 siblings, 1 reply; 11+ messages in thread
From: minyard @ 2016-12-22 19:18 UTC (permalink / raw)
  To: Bug 1651167, qemu-devel, Eric Blake; +Cc: Corey Minyard

From: Corey Minyard <cminyard@mvista.com>

Macro parameters should almost always have () around them when used.
llvm reported an error on this.

Remove redundant parenthesis and put parenthesis around the entire
macros with assignments in case they are used in an expression.

Remove some unused macros.

Reported in https://bugs.launchpad.net/bugs/1651167

Signed-off-by: Corey Minyard <cminyard@mvista.com>
---
 hw/ipmi/isa_ipmi_bt.c | 34 ++++++++++++----------------------
 1 file changed, 12 insertions(+), 22 deletions(-)

Changes in v2:
  * Put parenthesis around macros that had assignment in them.
  * Removed some redundant parenthesis.
  * Removed some macros that were not used.

diff --git a/hw/ipmi/isa_ipmi_bt.c b/hw/ipmi/isa_ipmi_bt.c
index f036617..68bf5cd 100644
--- a/hw/ipmi/isa_ipmi_bt.c
+++ b/hw/ipmi/isa_ipmi_bt.c
@@ -37,40 +37,30 @@
 #define IPMI_BT_HBUSY_BIT          6
 #define IPMI_BT_BBUSY_BIT          7
 
-#define IPMI_BT_CLR_WR_MASK        (1 << IPMI_BT_CLR_WR_BIT)
 #define IPMI_BT_GET_CLR_WR(d)      (((d) >> IPMI_BT_CLR_WR_BIT) & 0x1)
-#define IPMI_BT_SET_CLR_WR(d, v)   (d) = (((d) & ~IPMI_BT_CLR_WR_MASK) | \
-                                       (((v & 1) << IPMI_BT_CLR_WR_BIT)))
 
-#define IPMI_BT_CLR_RD_MASK        (1 << IPMI_BT_CLR_RD_BIT)
 #define IPMI_BT_GET_CLR_RD(d)      (((d) >> IPMI_BT_CLR_RD_BIT) & 0x1)
-#define IPMI_BT_SET_CLR_RD(d, v)   (d) = (((d) & ~IPMI_BT_CLR_RD_MASK) | \
-                                       (((v & 1) << IPMI_BT_CLR_RD_BIT)))
 
-#define IPMI_BT_H2B_ATN_MASK       (1 << IPMI_BT_H2B_ATN_BIT)
 #define IPMI_BT_GET_H2B_ATN(d)     (((d) >> IPMI_BT_H2B_ATN_BIT) & 0x1)
-#define IPMI_BT_SET_H2B_ATN(d, v)  (d) = (((d) & ~IPMI_BT_H2B_ATN_MASK) | \
-                                        (((v & 1) << IPMI_BT_H2B_ATN_BIT)))
 
 #define IPMI_BT_B2H_ATN_MASK       (1 << IPMI_BT_B2H_ATN_BIT)
 #define IPMI_BT_GET_B2H_ATN(d)     (((d) >> IPMI_BT_B2H_ATN_BIT) & 0x1)
-#define IPMI_BT_SET_B2H_ATN(d, v)  (d) = (((d) & ~IPMI_BT_B2H_ATN_MASK) | \
-                                        (((v & 1) << IPMI_BT_B2H_ATN_BIT)))
+#define IPMI_BT_SET_B2H_ATN(d, v)  ((d) = (((d) & ~IPMI_BT_B2H_ATN_MASK) | \
+                                        (((v) & 1) << IPMI_BT_B2H_ATN_BIT)))
 
 #define IPMI_BT_SMS_ATN_MASK       (1 << IPMI_BT_SMS_ATN_BIT)
 #define IPMI_BT_GET_SMS_ATN(d)     (((d) >> IPMI_BT_SMS_ATN_BIT) & 0x1)
-#define IPMI_BT_SET_SMS_ATN(d, v)  (d) = (((d) & ~IPMI_BT_SMS_ATN_MASK) | \
-                                        (((v & 1) << IPMI_BT_SMS_ATN_BIT)))
+#define IPMI_BT_SET_SMS_ATN(d, v)  ((d) = (((d) & ~IPMI_BT_SMS_ATN_MASK) | \
+                                        (((v) & 1) << IPMI_BT_SMS_ATN_BIT)))
 
 #define IPMI_BT_HBUSY_MASK         (1 << IPMI_BT_HBUSY_BIT)
 #define IPMI_BT_GET_HBUSY(d)       (((d) >> IPMI_BT_HBUSY_BIT) & 0x1)
-#define IPMI_BT_SET_HBUSY(d, v)    (d) = (((d) & ~IPMI_BT_HBUSY_MASK) | \
-                                       (((v & 1) << IPMI_BT_HBUSY_BIT)))
+#define IPMI_BT_SET_HBUSY(d, v)    ((d) = (((d) & ~IPMI_BT_HBUSY_MASK) | \
+                                       (((v) & 1) << IPMI_BT_HBUSY_BIT)))
 
 #define IPMI_BT_BBUSY_MASK         (1 << IPMI_BT_BBUSY_BIT)
-#define IPMI_BT_GET_BBUSY(d)       (((d) >> IPMI_BT_BBUSY_BIT) & 0x1)
-#define IPMI_BT_SET_BBUSY(d, v)    (d) = (((d) & ~IPMI_BT_BBUSY_MASK) | \
-                                       (((v & 1) << IPMI_BT_BBUSY_BIT)))
+#define IPMI_BT_SET_BBUSY(d, v)    ((d) = (((d) & ~IPMI_BT_BBUSY_MASK) | \
+                                       (((v) & 1) << IPMI_BT_BBUSY_BIT)))
 
 
 /* Mask register */
@@ -79,13 +69,13 @@
 
 #define IPMI_BT_B2H_IRQ_EN_MASK      (1 << IPMI_BT_B2H_IRQ_EN_BIT)
 #define IPMI_BT_GET_B2H_IRQ_EN(d)    (((d) >> IPMI_BT_B2H_IRQ_EN_BIT) & 0x1)
-#define IPMI_BT_SET_B2H_IRQ_EN(d, v) (d) = (((d) & ~IPMI_BT_B2H_IRQ_EN_MASK) | \
-                                        (((v & 1) << IPMI_BT_B2H_IRQ_EN_BIT)))
+#define IPMI_BT_SET_B2H_IRQ_EN(d, v) ((d) = (((d) & ~IPMI_BT_B2H_IRQ_EN_MASK) |\
+                                        (((v) & 1) << IPMI_BT_B2H_IRQ_EN_BIT)))
 
 #define IPMI_BT_B2H_IRQ_MASK         (1 << IPMI_BT_B2H_IRQ_BIT)
 #define IPMI_BT_GET_B2H_IRQ(d)       (((d) >> IPMI_BT_B2H_IRQ_BIT) & 0x1)
-#define IPMI_BT_SET_B2H_IRQ(d, v)    (d) = (((d) & ~IPMI_BT_B2H_IRQ_MASK) | \
-                                        (((v & 1) << IPMI_BT_B2H_IRQ_BIT)))
+#define IPMI_BT_SET_B2H_IRQ(d, v)    ((d) = (((d) & ~IPMI_BT_B2H_IRQ_MASK) | \
+                                        (((v) & 1) << IPMI_BT_B2H_IRQ_BIT)))
 
 typedef struct IPMIBT {
     IPMIBmc *bmc;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH v2] ipmi: Fix macro issues
  2016-12-22 19:18 ` [Qemu-devel] [PATCH v2] ipmi: Fix macro issues minyard
@ 2016-12-22 22:17   ` Eric Blake
  0 siblings, 0 replies; 11+ messages in thread
From: Eric Blake @ 2016-12-22 22:17 UTC (permalink / raw)
  To: minyard, Bug 1651167, qemu-devel; +Cc: Corey Minyard

[-- Attachment #1: Type: text/plain, Size: 781 bytes --]

On 12/22/2016 01:18 PM, minyard@acm.org wrote:
> From: Corey Minyard <cminyard@mvista.com>
> 
> Macro parameters should almost always have () around them when used.
> llvm reported an error on this.
> 
> Remove redundant parenthesis and put parenthesis around the entire
> macros with assignments in case they are used in an expression.
> 
> Remove some unused macros.
> 
> Reported in https://bugs.launchpad.net/bugs/1651167
> 
> Signed-off-by: Corey Minyard <cminyard@mvista.com>
> ---
>  hw/ipmi/isa_ipmi_bt.c | 34 ++++++++++++----------------------
>  1 file changed, 12 insertions(+), 22 deletions(-)

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PATCH v3] ipmi: Fix macro issues
  2016-12-19 15:47 [Qemu-devel] [Bug 1651167] [NEW] hw/ipmi/isa_ipmi_bt.c:283: suspect use of macro ? dcb
                   ` (3 preceding siblings ...)
  2016-12-22 19:18 ` [Qemu-devel] [PATCH v2] ipmi: Fix macro issues minyard
@ 2016-12-23 14:07 ` minyard
  2017-03-30 16:10   ` [Qemu-devel] [PATCH for-2.9? " Eric Blake
  2017-04-24  7:38 ` [Qemu-devel] [Bug 1651167] Re: hw/ipmi/isa_ipmi_bt.c:283: suspect use of macro ? Thomas Huth
  5 siblings, 1 reply; 11+ messages in thread
From: minyard @ 2016-12-23 14:07 UTC (permalink / raw)
  To: Bug 1651167, qemu-devel, Eric Blake; +Cc: Corey Minyard

From: Corey Minyard <cminyard@mvista.com>

Macro parameters should almost always have () around them when used.
llvm reported an error on this.

Remove redundant parenthesis and put parenthesis around the entire
macros with assignments in case they are used in an expression.

Remove some unused macros.

Reported in https://bugs.launchpad.net/bugs/1651167

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 hw/ipmi/isa_ipmi_bt.c | 34 ++++++++++++----------------------
 1 file changed, 12 insertions(+), 22 deletions(-)

Changed in v3:
  * Add Eric's reviewed-by.  Thanks!

Changes in v2:
  * Put parenthesis around macros that had assignment in them.
  * Removed some redundant parenthesis.
  * Removed some macros that were not used.

diff --git a/hw/ipmi/isa_ipmi_bt.c b/hw/ipmi/isa_ipmi_bt.c
index f036617..68bf5cd 100644
--- a/hw/ipmi/isa_ipmi_bt.c
+++ b/hw/ipmi/isa_ipmi_bt.c
@@ -37,40 +37,30 @@
 #define IPMI_BT_HBUSY_BIT          6
 #define IPMI_BT_BBUSY_BIT          7
 
-#define IPMI_BT_CLR_WR_MASK        (1 << IPMI_BT_CLR_WR_BIT)
 #define IPMI_BT_GET_CLR_WR(d)      (((d) >> IPMI_BT_CLR_WR_BIT) & 0x1)
-#define IPMI_BT_SET_CLR_WR(d, v)   (d) = (((d) & ~IPMI_BT_CLR_WR_MASK) | \
-                                       (((v & 1) << IPMI_BT_CLR_WR_BIT)))
 
-#define IPMI_BT_CLR_RD_MASK        (1 << IPMI_BT_CLR_RD_BIT)
 #define IPMI_BT_GET_CLR_RD(d)      (((d) >> IPMI_BT_CLR_RD_BIT) & 0x1)
-#define IPMI_BT_SET_CLR_RD(d, v)   (d) = (((d) & ~IPMI_BT_CLR_RD_MASK) | \
-                                       (((v & 1) << IPMI_BT_CLR_RD_BIT)))
 
-#define IPMI_BT_H2B_ATN_MASK       (1 << IPMI_BT_H2B_ATN_BIT)
 #define IPMI_BT_GET_H2B_ATN(d)     (((d) >> IPMI_BT_H2B_ATN_BIT) & 0x1)
-#define IPMI_BT_SET_H2B_ATN(d, v)  (d) = (((d) & ~IPMI_BT_H2B_ATN_MASK) | \
-                                        (((v & 1) << IPMI_BT_H2B_ATN_BIT)))
 
 #define IPMI_BT_B2H_ATN_MASK       (1 << IPMI_BT_B2H_ATN_BIT)
 #define IPMI_BT_GET_B2H_ATN(d)     (((d) >> IPMI_BT_B2H_ATN_BIT) & 0x1)
-#define IPMI_BT_SET_B2H_ATN(d, v)  (d) = (((d) & ~IPMI_BT_B2H_ATN_MASK) | \
-                                        (((v & 1) << IPMI_BT_B2H_ATN_BIT)))
+#define IPMI_BT_SET_B2H_ATN(d, v)  ((d) = (((d) & ~IPMI_BT_B2H_ATN_MASK) | \
+                                        (((v) & 1) << IPMI_BT_B2H_ATN_BIT)))
 
 #define IPMI_BT_SMS_ATN_MASK       (1 << IPMI_BT_SMS_ATN_BIT)
 #define IPMI_BT_GET_SMS_ATN(d)     (((d) >> IPMI_BT_SMS_ATN_BIT) & 0x1)
-#define IPMI_BT_SET_SMS_ATN(d, v)  (d) = (((d) & ~IPMI_BT_SMS_ATN_MASK) | \
-                                        (((v & 1) << IPMI_BT_SMS_ATN_BIT)))
+#define IPMI_BT_SET_SMS_ATN(d, v)  ((d) = (((d) & ~IPMI_BT_SMS_ATN_MASK) | \
+                                        (((v) & 1) << IPMI_BT_SMS_ATN_BIT)))
 
 #define IPMI_BT_HBUSY_MASK         (1 << IPMI_BT_HBUSY_BIT)
 #define IPMI_BT_GET_HBUSY(d)       (((d) >> IPMI_BT_HBUSY_BIT) & 0x1)
-#define IPMI_BT_SET_HBUSY(d, v)    (d) = (((d) & ~IPMI_BT_HBUSY_MASK) | \
-                                       (((v & 1) << IPMI_BT_HBUSY_BIT)))
+#define IPMI_BT_SET_HBUSY(d, v)    ((d) = (((d) & ~IPMI_BT_HBUSY_MASK) | \
+                                       (((v) & 1) << IPMI_BT_HBUSY_BIT)))
 
 #define IPMI_BT_BBUSY_MASK         (1 << IPMI_BT_BBUSY_BIT)
-#define IPMI_BT_GET_BBUSY(d)       (((d) >> IPMI_BT_BBUSY_BIT) & 0x1)
-#define IPMI_BT_SET_BBUSY(d, v)    (d) = (((d) & ~IPMI_BT_BBUSY_MASK) | \
-                                       (((v & 1) << IPMI_BT_BBUSY_BIT)))
+#define IPMI_BT_SET_BBUSY(d, v)    ((d) = (((d) & ~IPMI_BT_BBUSY_MASK) | \
+                                       (((v) & 1) << IPMI_BT_BBUSY_BIT)))
 
 
 /* Mask register */
@@ -79,13 +69,13 @@
 
 #define IPMI_BT_B2H_IRQ_EN_MASK      (1 << IPMI_BT_B2H_IRQ_EN_BIT)
 #define IPMI_BT_GET_B2H_IRQ_EN(d)    (((d) >> IPMI_BT_B2H_IRQ_EN_BIT) & 0x1)
-#define IPMI_BT_SET_B2H_IRQ_EN(d, v) (d) = (((d) & ~IPMI_BT_B2H_IRQ_EN_MASK) | \
-                                        (((v & 1) << IPMI_BT_B2H_IRQ_EN_BIT)))
+#define IPMI_BT_SET_B2H_IRQ_EN(d, v) ((d) = (((d) & ~IPMI_BT_B2H_IRQ_EN_MASK) |\
+                                        (((v) & 1) << IPMI_BT_B2H_IRQ_EN_BIT)))
 
 #define IPMI_BT_B2H_IRQ_MASK         (1 << IPMI_BT_B2H_IRQ_BIT)
 #define IPMI_BT_GET_B2H_IRQ(d)       (((d) >> IPMI_BT_B2H_IRQ_BIT) & 0x1)
-#define IPMI_BT_SET_B2H_IRQ(d, v)    (d) = (((d) & ~IPMI_BT_B2H_IRQ_MASK) | \
-                                        (((v & 1) << IPMI_BT_B2H_IRQ_BIT)))
+#define IPMI_BT_SET_B2H_IRQ(d, v)    ((d) = (((d) & ~IPMI_BT_B2H_IRQ_MASK) | \
+                                        (((v) & 1) << IPMI_BT_B2H_IRQ_BIT)))
 
 typedef struct IPMIBT {
     IPMIBmc *bmc;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.9? v3] ipmi: Fix macro issues
  2016-12-23 14:07 ` [Qemu-devel] [PATCH v3] " minyard
@ 2017-03-30 16:10   ` Eric Blake
  0 siblings, 0 replies; 11+ messages in thread
From: Eric Blake @ 2017-03-30 16:10 UTC (permalink / raw)
  To: minyard, Bug 1651167, qemu-devel; +Cc: Corey Minyard

[-- Attachment #1: Type: text/plain, Size: 5170 bytes --]

Ping - did this ever get applied?

On 12/23/2016 08:07 AM, minyard@acm.org wrote:
> From: Corey Minyard <cminyard@mvista.com>
> 
> Macro parameters should almost always have () around them when used.
> llvm reported an error on this.
> 
> Remove redundant parenthesis and put parenthesis around the entire
> macros with assignments in case they are used in an expression.
> 
> Remove some unused macros.
> 
> Reported in https://bugs.launchpad.net/bugs/1651167
> 
> Signed-off-by: Corey Minyard <cminyard@mvista.com>
> Reviewed-by: Eric Blake <eblake@redhat.com>
> ---
>  hw/ipmi/isa_ipmi_bt.c | 34 ++++++++++++----------------------
>  1 file changed, 12 insertions(+), 22 deletions(-)
> 
> Changed in v3:
>   * Add Eric's reviewed-by.  Thanks!
> 
> Changes in v2:
>   * Put parenthesis around macros that had assignment in them.
>   * Removed some redundant parenthesis.
>   * Removed some macros that were not used.
> 
> diff --git a/hw/ipmi/isa_ipmi_bt.c b/hw/ipmi/isa_ipmi_bt.c
> index f036617..68bf5cd 100644
> --- a/hw/ipmi/isa_ipmi_bt.c
> +++ b/hw/ipmi/isa_ipmi_bt.c
> @@ -37,40 +37,30 @@
>  #define IPMI_BT_HBUSY_BIT          6
>  #define IPMI_BT_BBUSY_BIT          7
>  
> -#define IPMI_BT_CLR_WR_MASK        (1 << IPMI_BT_CLR_WR_BIT)
>  #define IPMI_BT_GET_CLR_WR(d)      (((d) >> IPMI_BT_CLR_WR_BIT) & 0x1)
> -#define IPMI_BT_SET_CLR_WR(d, v)   (d) = (((d) & ~IPMI_BT_CLR_WR_MASK) | \
> -                                       (((v & 1) << IPMI_BT_CLR_WR_BIT)))
>  
> -#define IPMI_BT_CLR_RD_MASK        (1 << IPMI_BT_CLR_RD_BIT)
>  #define IPMI_BT_GET_CLR_RD(d)      (((d) >> IPMI_BT_CLR_RD_BIT) & 0x1)
> -#define IPMI_BT_SET_CLR_RD(d, v)   (d) = (((d) & ~IPMI_BT_CLR_RD_MASK) | \
> -                                       (((v & 1) << IPMI_BT_CLR_RD_BIT)))
>  
> -#define IPMI_BT_H2B_ATN_MASK       (1 << IPMI_BT_H2B_ATN_BIT)
>  #define IPMI_BT_GET_H2B_ATN(d)     (((d) >> IPMI_BT_H2B_ATN_BIT) & 0x1)
> -#define IPMI_BT_SET_H2B_ATN(d, v)  (d) = (((d) & ~IPMI_BT_H2B_ATN_MASK) | \
> -                                        (((v & 1) << IPMI_BT_H2B_ATN_BIT)))
>  
>  #define IPMI_BT_B2H_ATN_MASK       (1 << IPMI_BT_B2H_ATN_BIT)
>  #define IPMI_BT_GET_B2H_ATN(d)     (((d) >> IPMI_BT_B2H_ATN_BIT) & 0x1)
> -#define IPMI_BT_SET_B2H_ATN(d, v)  (d) = (((d) & ~IPMI_BT_B2H_ATN_MASK) | \
> -                                        (((v & 1) << IPMI_BT_B2H_ATN_BIT)))
> +#define IPMI_BT_SET_B2H_ATN(d, v)  ((d) = (((d) & ~IPMI_BT_B2H_ATN_MASK) | \
> +                                        (((v) & 1) << IPMI_BT_B2H_ATN_BIT)))
>  
>  #define IPMI_BT_SMS_ATN_MASK       (1 << IPMI_BT_SMS_ATN_BIT)
>  #define IPMI_BT_GET_SMS_ATN(d)     (((d) >> IPMI_BT_SMS_ATN_BIT) & 0x1)
> -#define IPMI_BT_SET_SMS_ATN(d, v)  (d) = (((d) & ~IPMI_BT_SMS_ATN_MASK) | \
> -                                        (((v & 1) << IPMI_BT_SMS_ATN_BIT)))
> +#define IPMI_BT_SET_SMS_ATN(d, v)  ((d) = (((d) & ~IPMI_BT_SMS_ATN_MASK) | \
> +                                        (((v) & 1) << IPMI_BT_SMS_ATN_BIT)))
>  
>  #define IPMI_BT_HBUSY_MASK         (1 << IPMI_BT_HBUSY_BIT)
>  #define IPMI_BT_GET_HBUSY(d)       (((d) >> IPMI_BT_HBUSY_BIT) & 0x1)
> -#define IPMI_BT_SET_HBUSY(d, v)    (d) = (((d) & ~IPMI_BT_HBUSY_MASK) | \
> -                                       (((v & 1) << IPMI_BT_HBUSY_BIT)))
> +#define IPMI_BT_SET_HBUSY(d, v)    ((d) = (((d) & ~IPMI_BT_HBUSY_MASK) | \
> +                                       (((v) & 1) << IPMI_BT_HBUSY_BIT)))
>  
>  #define IPMI_BT_BBUSY_MASK         (1 << IPMI_BT_BBUSY_BIT)
> -#define IPMI_BT_GET_BBUSY(d)       (((d) >> IPMI_BT_BBUSY_BIT) & 0x1)
> -#define IPMI_BT_SET_BBUSY(d, v)    (d) = (((d) & ~IPMI_BT_BBUSY_MASK) | \
> -                                       (((v & 1) << IPMI_BT_BBUSY_BIT)))
> +#define IPMI_BT_SET_BBUSY(d, v)    ((d) = (((d) & ~IPMI_BT_BBUSY_MASK) | \
> +                                       (((v) & 1) << IPMI_BT_BBUSY_BIT)))
>  
>  
>  /* Mask register */
> @@ -79,13 +69,13 @@
>  
>  #define IPMI_BT_B2H_IRQ_EN_MASK      (1 << IPMI_BT_B2H_IRQ_EN_BIT)
>  #define IPMI_BT_GET_B2H_IRQ_EN(d)    (((d) >> IPMI_BT_B2H_IRQ_EN_BIT) & 0x1)
> -#define IPMI_BT_SET_B2H_IRQ_EN(d, v) (d) = (((d) & ~IPMI_BT_B2H_IRQ_EN_MASK) | \
> -                                        (((v & 1) << IPMI_BT_B2H_IRQ_EN_BIT)))
> +#define IPMI_BT_SET_B2H_IRQ_EN(d, v) ((d) = (((d) & ~IPMI_BT_B2H_IRQ_EN_MASK) |\
> +                                        (((v) & 1) << IPMI_BT_B2H_IRQ_EN_BIT)))
>  
>  #define IPMI_BT_B2H_IRQ_MASK         (1 << IPMI_BT_B2H_IRQ_BIT)
>  #define IPMI_BT_GET_B2H_IRQ(d)       (((d) >> IPMI_BT_B2H_IRQ_BIT) & 0x1)
> -#define IPMI_BT_SET_B2H_IRQ(d, v)    (d) = (((d) & ~IPMI_BT_B2H_IRQ_MASK) | \
> -                                        (((v & 1) << IPMI_BT_B2H_IRQ_BIT)))
> +#define IPMI_BT_SET_B2H_IRQ(d, v)    ((d) = (((d) & ~IPMI_BT_B2H_IRQ_MASK) | \
> +                                        (((v) & 1) << IPMI_BT_B2H_IRQ_BIT)))
>  
>  typedef struct IPMIBT {
>      IPMIBmc *bmc;
> 

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Qemu-devel] [Bug 1651167] Re: hw/ipmi/isa_ipmi_bt.c:283: suspect use of macro ?
  2016-12-19 15:47 [Qemu-devel] [Bug 1651167] [NEW] hw/ipmi/isa_ipmi_bt.c:283: suspect use of macro ? dcb
                   ` (4 preceding siblings ...)
  2016-12-23 14:07 ` [Qemu-devel] [PATCH v3] " minyard
@ 2017-04-24  7:38 ` Thomas Huth
  5 siblings, 0 replies; 11+ messages in thread
From: Thomas Huth @ 2017-04-24  7:38 UTC (permalink / raw)
  To: qemu-devel

Fix has been included here:
http://git.qemu.org/?p=qemu.git;a=commitdiff;h=cb9a05a4f169347f85

** Changed in: qemu
       Status: In Progress => Fix Released

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1651167

Title:
  hw/ipmi/isa_ipmi_bt.c:283: suspect use of macro ?

Status in QEMU:
  Fix Released

Bug description:
  I just had a go at compiling qemu trunk with
  llvm trunk. It said:

  hw/ipmi/isa_ipmi_bt.c:283:31: warning: logical not is only applied to
  the left hand side of this bitwise operator [-Wlogical-not-
  parentheses]

  Source code is

             IPMI_BT_SET_HBUSY(ib->control_reg,
                                !IPMI_BT_GET_HBUSY(ib->control_reg));

  That use of ! causes trouble. The SET and GET
  macros are defined as:

  #define IPMI_BT_GET_HBUSY(d)       (((d) >> IPMI_BT_HBUSY_BIT) & 0x1)
  #define IPMI_BT_SET_HBUSY(d, v)    (d) = (((d) & ~IPMI_BT_HBUSY_MASK) | \
                                         (((v & 1) << IPMI_BT_HBUSY_BIT)))

  I can make the compiler shut up by adding extra () in the last
  use of v in the SET macro, like this:

  #define IPMI_BT_SET_HBUSY(d, v)    (d) = (((d) & ~IPMI_BT_HBUSY_MASK) | \
                                         ((((v) & 1) << IPMI_BT_HBUSY_BIT)))

  I think this is standard good practice when using macro parameters
  anyway.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1651167/+subscriptions

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-04-24  7:46 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-19 15:47 [Qemu-devel] [Bug 1651167] [NEW] hw/ipmi/isa_ipmi_bt.c:283: suspect use of macro ? dcb
2016-12-22 14:20 ` Corey Minyard
2016-12-22 14:25 ` [Qemu-devel] [Bug 1651167] " cminyard
2016-12-22 14:30 ` [Qemu-devel] [PATCH] ipmi: Add parenthesis around some macro parameters minyard
2016-12-22 15:01   ` Eric Blake
2016-12-22 17:48     ` Corey Minyard
2016-12-22 19:18 ` [Qemu-devel] [PATCH v2] ipmi: Fix macro issues minyard
2016-12-22 22:17   ` Eric Blake
2016-12-23 14:07 ` [Qemu-devel] [PATCH v3] " minyard
2017-03-30 16:10   ` [Qemu-devel] [PATCH for-2.9? " Eric Blake
2017-04-24  7:38 ` [Qemu-devel] [Bug 1651167] Re: hw/ipmi/isa_ipmi_bt.c:283: suspect use of macro ? Thomas Huth

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.