hw/ipmi/isa_ipmi_bt.c:283: suspect use of macro ?
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
Signature · 12 lines
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
Quoted 20 lines · dcb
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)))
Quoted 8 lines
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
Quoted 5 lines
** Affects: qemu
Importance: Undecided
Status: New
** Changed in: qemu
Assignee: (unassigned) => cminyard (minyard)
** Changed in: qemu
Status: New => In Progress
Signature · 12 lines
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
PATCH 1/1 ipmi: Add parenthesis around some macro parameters
In reply to dcbFrom: Corey Minyard <[email protected]>
Macro parameters should almost always have () around them when used. llvm reported an error on this.
Reported in https://bugs.launchpad.net/bugs/1651167
--- hw/ipmi/isa_ipmi_bt.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
hw/ipmi/isa_ipmi_bt.c +9 -9
@@ -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;
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH] ipmi: Add parenthesis around some macro parameters
Quoted 17 lines · On 12/22/2016 08:30 AM, [email protected] wrote:
From: Corey Minyard <[email protected]>
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 <[email protected]>--- hw/ipmi/isa_ipmi_bt.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)hw/ipmi/isa_ipmi_bt.c +0
-0
hw/ipmi/isa_ipmi_bt.c line 42
Quoted 3 lines
hw/ipmi/isa_ipmi_bt.c +0
-0@@ -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;
hw/ipmi/isa_ipmi_bt.c line 43
Quoted 2 lines
hw/ipmi/isa_ipmi_bt.c +1
-1- (((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)))hw/ipmi/isa_ipmi_bt.c line 48
Quoted 6 lines
hw/ipmi/isa_ipmi_bt.c +1
-1#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.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH] ipmi: Add parenthesis around some macro parameters
Quoted 13 lines · Eric Blake
Quoted 12 lines · On 12/22/2016 08:30 AM, [email protected] wrote:
From: Corey Minyard <[email protected]>
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 <[email protected]>--- hw/ipmi/isa_ipmi_bt.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
Quoted 10 lines
hw/ipmi/isa_ipmi_bt.c line 42
Quoted 8 lines
hw/ipmi/isa_ipmi_bt.c +0
-0@@ -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
Quoted 18 lines
hw/ipmi/isa_ipmi_bt.c line 43
Quoted 2 lines
hw/ipmi/isa_ipmi_bt.c +1
-1- (((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)))hw/ipmi/isa_ipmi_bt.c line 48
Quoted 6 lines
hw/ipmi/isa_ipmi_bt.c +1
-1#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.
PATCH v2 1/1 ipmi: Fix macro issues
In reply to dcbFrom: Corey Minyard <[email protected]>
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
--- 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.
hw/ipmi/isa_ipmi_bt.c +12 -22
@@ -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;
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v2] ipmi: Fix macro issues
Quoted 8 lines · On 12/22/2016 01:18 PM, [email protected] wrote:
From: Corey Minyard <[email protected]>
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.
Quoted 8 lines
Remove some unused macros.
Reported in https://bugs.launchpad.net/bugs/1651167
Signed-off-by Corey Minyard <[email protected]>--- hw/ipmi/isa_ipmi_bt.c | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v3 1/1 ipmi: Fix macro issues
In reply to dcbFrom: Corey Minyard <[email protected]>
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
--- 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.
hw/ipmi/isa_ipmi_bt.c +12 -22
@@ -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;
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH for-2.9? v3] ipmi: Fix macro issues
Ping - did this ever get applied?
Quoted 98 lines · On 12/23/2016 08:07 AM, [email protected] wrote:
From: Corey Minyard <[email protected]>
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 <[email protected]>Reviewed-by Eric Blake <[email protected]>--- 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.hw/ipmi/isa_ipmi_bt.c +12
-22@@ -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;
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Fix has been included here:
http://git.qemu.org/?p=qemu.git;a=commitdiff;h=cb9a05a4f169347f85
** Changed in: qemu
Status: In Progress => Fix Released
Signature · 12 lines
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