blob: 4ddb5226c53f641afb0ed8b2879835533a82a425 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
mistranslation: 0.960
other: 0.855
device: 0.812
semantic: 0.811
socket: 0.783
vnc: 0.741
instruction: 0.683
graphic: 0.661
boot: 0.654
network: 0.587
assembly: 0.537
KVM: 0.520
target/ppc/int_helper.c:2806: strange expression ?
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 : zone_lead;
Which I read as
zone_digit = (i * 2) ? (b->u8[BCD_DIG_BYTE(i * 2)] >> 4) : zone_lead;
so I think the compiler warning is for the i * 2 lhs of the ?.
I am not sure what to suggest as a bugfix.
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 :
> zone_lead;
Also, looking at BCD_DIG_BYTE():
#if defined(HOST_WORDS_BIGENDIAN)
#define BCD_DIG_BYTE(n) (15 - (n/2))
#else
#define BCD_DIG_BYTE(n) (n/2)
#endif
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
> so it is just as easy to write 'i ? ...' instead of the weirder
> '(i * 2) ? ...'.
I suspect it is just possible that the i * 2 expression is a typo
for something else, perhaps i & 2 or i << 2 or i >> 2 or something else.
I don't know the code so I am unable to offer better guidance.
Patch has been posted to the mailing list:
https://lists.gnu.org/archive/html/qemu-devel/2017-01/msg02008.html
Fix had been committed here:
http://git.qemu.org/?p=qemu.git;a=commitdiff;h=365206aeb3d0bb72043d
|