[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] ipmi: Add parenthesis around some macro paramet
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH] ipmi: Add parenthesis around some macro parameters |
Date: |
Thu, 22 Dec 2016 09:01:39 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 |
On 12/22/2016 08:30 AM, address@hidden wrote:
> From: Corey Minyard <address@hidden>
>
> 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 <address@hidden>
> ---
> 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
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [Bug 1651167] [NEW] hw/ipmi/isa_ipmi_bt.c:283: suspect use of macro ?, dcb, 2016/12/19
- Re: [Qemu-devel] [Bug 1651167] [NEW] hw/ipmi/isa_ipmi_bt.c:283: suspect use of macro ?, Corey Minyard, 2016/12/22
- [Qemu-devel] [Bug 1651167] Re: hw/ipmi/isa_ipmi_bt.c:283: suspect use of macro ?, cminyard, 2016/12/22
- [Qemu-devel] [PATCH] ipmi: Add parenthesis around some macro parameters, minyard, 2016/12/22
- Re: [Qemu-devel] [PATCH] ipmi: Add parenthesis around some macro parameters,
Eric Blake <=
- [Qemu-devel] [PATCH v2] ipmi: Fix macro issues, minyard, 2016/12/22
- [Qemu-devel] [PATCH v3] ipmi: Fix macro issues, minyard, 2016/12/23