Skip to contentSkip to conversation

target-sparc: Fix wrong printf argument

PATCH Applied Stefan Weil 2 participants 2 messages May 12, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target-sparc: Fix wrong printf argument

cpu_get_ccr() returns a target_ulong, so a type cast is needed to avoid wrong output on big endian hosts. We could also use TARGET_FMT_lx, but that would print 8 instead of 2 digits.

---
 target-sparc/helper.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
target-sparc/helper.c +1 -1
index 4642122..582de10 100644
@@ -1490,7 +1490,7 @@ void cpu_dump_state(CPUState *env, FILE *f,
     }
 #ifdef TARGET_SPARC64
     cpu_fprintf(f, "pstate: %08x ccr: %02x (icc: ", env->pstate,
-                cpu_get_ccr(env));
+                (unsigned)cpu_get_ccr(env));
     cpu_print_cc(f, cpu_fprintf, cpu_get_ccr(env) << PSR_CARRY_SHIFT);
     cpu_fprintf(f, " xcc: ");
     cpu_print_cc(f, cpu_fprintf, cpu_get_ccr(env) << (PSR_CARRY_SHIFT - 4));
Signature · 1 line
1.7.1
Applied
#1 lore raw

Thanks, applied.

Another solution would have been to change the return value to uint32_t.

Quoted 28 lines · Stefan Weil

cpu_get_ccr() returns a target_ulong, so a type cast is needed to avoid
wrong output on big endian hosts. We could also use TARGET_FMT_lx, but that would print 8 instead of 2 digits.

---

  target-sparc/helper.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/target-sparc/helper.c b/target-sparc/helper.c index 4642122..582de10 100644
--- a/target-sparc/helper.c
+++ b/target-sparc/helper.c
@@ -1490,7 +1490,7 @@ void cpu_dump_state(CPUState *env, FILE *f,

     }
  #ifdef TARGET_SPARC64
     cpu_fprintf(f, "pstate: %08x ccr: %02x (icc: ", env->pstate,
 -                cpu_get_ccr(env));
 +                (unsigned)cpu_get_ccr(env));
     cpu_print_cc(f, cpu_fprintf, cpu_get_ccr(env) << PSR_CARRY_SHIFT);
     cpu_fprintf(f, " xcc: ");
     cpu_print_cc(f, cpu_fprintf, cpu_get_ccr(env) << (PSR_CARRY_SHIFT - 4));

--
1.7.1