qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, Aurelien Jarno <aurelien@aurel32.net>
Subject: [Qemu-devel] [PULL 3/4] target-s390x: fix CONVERT TO BINARY (CVD, CVDY)
Date: Tue,  7 Jul 2015 17:52:40 +0200	[thread overview]
Message-ID: <1436284361-5745-4-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1436284361-5745-1-git-send-email-agraf@suse.de>

From: Aurelien Jarno <aurelien@aurel32.net>

current_number being shift left by more than 32 bits, we can't use a
simple int. Similarly use an int64_t type for the input binary value,
to not get the -2^31 case wrong. Finally don't initialize shift to 4,
it's already done in the for loop.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 target-s390x/int_helper.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/target-s390x/int_helper.c b/target-s390x/int_helper.c
index 2c2b3f6..a46c736 100644
--- a/target-s390x/int_helper.c
+++ b/target-s390x/int_helper.c
@@ -121,11 +121,12 @@ uint64_t HELPER(clz)(uint64_t v)
     return clz64(v);
 }
 
-uint64_t HELPER(cvd)(int32_t bin)
+uint64_t HELPER(cvd)(int32_t reg)
 {
     /* positive 0 */
     uint64_t dec = 0x0c;
-    int shift = 4;
+    int64_t bin = reg;
+    int shift;
 
     if (bin < 0) {
         bin = -bin;
@@ -133,9 +134,7 @@ uint64_t HELPER(cvd)(int32_t bin)
     }
 
     for (shift = 4; (shift < 64) && bin; shift += 4) {
-        int current_number = bin % 10;
-
-        dec |= (current_number) << shift;
+        dec |= (bin % 10) << shift;
         bin /= 10;
     }
 
-- 
1.7.12.4

  parent reply	other threads:[~2015-07-07 15:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-07 15:52 [Qemu-devel] [PULL 0/4] s390 patch queue 2015-07-07 Alexander Graf
2015-07-07 15:52 ` [Qemu-devel] [PULL 1/4] target-s390x: fix MOVE LONG instruction Alexander Graf
2015-07-07 15:52 ` [Qemu-devel] [PULL 2/4] target-s390x: fix EXECUTE instruction executing TRT Alexander Graf
2015-07-07 15:52 ` Alexander Graf [this message]
2015-07-07 15:52 ` [Qemu-devel] [PULL 4/4] tcg/s390: fix branch target change during code retranslation Alexander Graf
2015-07-08 10:40 ` [Qemu-devel] [PULL 0/4] s390 patch queue 2015-07-07 Peter Maydell

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=1436284361-5745-4-git-send-email-agraf@suse.de \
    --to=agraf@suse.de \
    --cc=aurelien@aurel32.net \
    --cc=peter.maydell@linaro.org \
    --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).