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

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.