[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [Bug 1655708] [NEW] target/ppc/int_helper.c:2806: stran
Re: [Qemu-devel] [Bug 1655708] [NEW] target/ppc/int_helper.c:2806: strange expression ?
Wed, 11 Jan 2017 11:12:38 -0600
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0
On 01/11/2017 10:41 AM, dcb wrote:
> Public bug reported:
> target/ppc/int_helper.c:2806:25: warning: ‘*’ in boolean context,
> suggest ‘&&’ instead [-Wint-in-bool-context]
> Source code is
> zone_digit = (i * 2) ? b->u8[BCD_DIG_BYTE(i * 2)] >> 4 :
Also, looking at BCD_DIG_BYTE():
#define BCD_DIG_BYTE(n) (15 - (n/2))
#define BCD_DIG_BYTE(n) (n/2)
Oops. n is under-parenthesized, and will cause invalid expansions for
some expressions. Let's fix that as well.
> so I think the compiler warning is for the i * 2 lhs of the ?.
Yes - the compiler is complaining that 'i * 2' can only be non-zero if
'i' was non-zero (given that the code occurs in a loop for i between 0
and 16), so it is just as easy to write 'i ? ...' instead of the weirder
'(i * 2) ? ...'.
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Description: OpenPGP digital signature