qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com>, qemu-ppc@nongnu.org
Cc: qemu-devel@nongnu.org, david@gibson.dropbear.id.au,
	nikunj@linux.vnet.ibm.com, 655708@bugs.launchpad.net,
	thuth@redhat.com
Subject: Re: [Qemu-devel] [PATCH] ppc: Fix a warning in bcdcfz code and improve BCD_DIG_BYTE macro
Date: Wed, 11 Jan 2017 14:59:29 -0600	[thread overview]
Message-ID: <6122a696-b85c-4fc8-b0be-a3b80fbb761f@redhat.com> (raw)
In-Reply-To: <1484160658-15419-1-git-send-email-joserz@linux.vnet.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 1610 bytes --]

On 01/11/2017 12:50 PM, Jose Ricardo Ziviani wrote:
> This commit fixes a warning in the code "(i * 2) ? .. : ..", which
> should be better as "(i) ? .. : ..", and improves the BCD_DIG_BYTE

Could remove the () around i here.

> macro by placing parentheses around its argument to avoid possible
> expansion issues like: BCD_DIG_BYTE(i + j).
> 
> Signed-off-by: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com>
> ---
>  target/ppc/int_helper.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c
> index 24e5964..d889084 100644
> --- a/target/ppc/int_helper.c
> +++ b/target/ppc/int_helper.c
> @@ -2583,9 +2583,9 @@ void helper_vsubecuq(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
>  #define NATIONAL_NEG    0x2D
>  
>  #if defined(HOST_WORDS_BIGENDIAN)
> -#define BCD_DIG_BYTE(n) (15 - (n/2))
> +#define BCD_DIG_BYTE(n) (15 - ((n) / 2))
>  #else
> -#define BCD_DIG_BYTE(n) (n/2)
> +#define BCD_DIG_BYTE(n) ((n) / 2)
>  #endif
>  
>  static int bcd_get_sgn(ppc_avr_t *bcd)
> @@ -2908,7 +2908,7 @@ uint32_t helper_bcdcfz(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps)
>      }
>  
>      for (i = 0; i < 16; i++) {
> -        zone_digit = (i * 2) ? b->u8[BCD_DIG_BYTE(i * 2)] >> 4 : zone_lead;
> +        zone_digit = (i) ? b->u8[BCD_DIG_BYTE(i * 2)] >> 4 : zone_lead;

Extra (); I'd go with zone_digit = i ? ...

With that tweak,
Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

      reply	other threads:[~2017-01-11 20:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-11 18:50 [Qemu-devel] [PATCH] ppc: Fix a warning in bcdcfz code and improve BCD_DIG_BYTE macro Jose Ricardo Ziviani
2017-01-11 20:59 ` Eric Blake [this message]

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=6122a696-b85c-4fc8-b0be-a3b80fbb761f@redhat.com \
    --to=eblake@redhat.com \
    --cc=655708@bugs.launchpad.net \
    --cc=david@gibson.dropbear.id.au \
    --cc=joserz@linux.vnet.ibm.com \
    --cc=nikunj@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=thuth@redhat.com \
    /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).