qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCHi v2] ppc: Fix a warning in bcdcfz code and improve BCD_DIG_BYTE macro
@ 2017-01-11 21:11 Jose Ricardo Ziviani
  2017-01-11 23:22 ` David Gibson
  0 siblings, 1 reply; 2+ messages in thread
From: Jose Ricardo Ziviani @ 2017-01-11 21:11 UTC (permalink / raw)
  To: qemu-ppc; +Cc: qemu-devel, david, nikunj, eblake, 655708, thuth

This commit fixes a warning in the code "(i * 2) ? .. : ..", which
should be better as "i ? .. : ..", and improves the BCD_DIG_BYTE
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>
Reviewed-by: Eric Blake <eblake@redhat.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..bd8282c 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;
         digit = b->u8[BCD_DIG_BYTE(i * 2)] & 0xF;
         if (unlikely(zone_digit != zone_lead || digit > 0x9)) {
             invalid = 1;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCHi v2] ppc: Fix a warning in bcdcfz code and improve BCD_DIG_BYTE macro
  2017-01-11 21:11 [Qemu-devel] [PATCHi v2] ppc: Fix a warning in bcdcfz code and improve BCD_DIG_BYTE macro Jose Ricardo Ziviani
@ 2017-01-11 23:22 ` David Gibson
  0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2017-01-11 23:22 UTC (permalink / raw)
  To: Jose Ricardo Ziviani; +Cc: qemu-ppc, qemu-devel, nikunj, eblake, 655708, thuth

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

On Wed, Jan 11, 2017 at 07:11:25PM -0200, 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
> 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>
> Reviewed-by: Eric Blake <eblake@redhat.com>

Applied to ppc-for-2.9.

> ---
>  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..bd8282c 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;
>          digit = b->u8[BCD_DIG_BYTE(i * 2)] & 0xF;
>          if (unlikely(zone_digit != zone_lead || digit > 0x9)) {
>              invalid = 1;

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-01-12  0:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-11 21:11 [Qemu-devel] [PATCHi v2] ppc: Fix a warning in bcdcfz code and improve BCD_DIG_BYTE macro Jose Ricardo Ziviani
2017-01-11 23:22 ` David Gibson

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).