From: joserz@linux.vnet.ibm.com
To: Eric Blake <1655708@bugs.launchpad.net>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [Bug 1655708] [NEW] target/ppc/int_helper.c:2806: strange expression ?
Date: Wed, 11 Jan 2017 16:01:42 -0200 [thread overview]
Message-ID: <20170111180142.GA8281@pacoca> (raw)
In-Reply-To: <4fc41772-1607-7e55-ffa1-80e3579b964d@redhat.com>
On Wed, Jan 11, 2017 at 05:12:38PM -0000, Eric Blake wrote:
> 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.
>
Hello guys!!
Do you mean something like:
BCD_DIG_BYTE(n) (15 - ((n)/2)) and BCD_DIG_BYTE(n) ((n)/2) ?
to avoid issues like BCD_DIG_BYTE(i + 3) that will expand to (i + 3/2)
instead of ((i + 3)/2), right?
>
> > 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) ? ...'.
>
Yes, Eric is correct it's meant to be "(i) ? .. : .." because the sign
is located at position 0. I'm improving it. I'll send a patch for them
today.
Thanks!
next prev parent reply other threads:[~2017-01-11 18:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-11 16:41 [Qemu-devel] [Bug 1655708] [NEW] target/ppc/int_helper.c:2806: strange expression ? dcb
2017-01-11 17:12 ` Eric Blake
2017-01-11 17:19 ` Thomas Huth
2017-01-11 18:01 ` joserz [this message]
2017-01-11 18:53 ` [Qemu-devel] [Bug 1655708] " Jose R. Ziviani
2017-01-11 20:09 ` dcb
2017-01-18 15:44 ` Thomas Huth
2017-07-20 12:44 ` Thomas Huth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170111180142.GA8281@pacoca \
--to=joserz@linux.vnet.ibm.com \
--cc=1655708@bugs.launchpad.net \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).