qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] target-tricore: Fix two helper functions (clang warnings)
@ 2015-03-07 14:43 Stefan Weil
  2015-03-09 16:14 ` Bastian Koppelmann
  2015-03-23 14:41 ` Bastian Koppelmann
  0 siblings, 2 replies; 4+ messages in thread
From: Stefan Weil @ 2015-03-07 14:43 UTC (permalink / raw)
  To: QEMU Developer; +Cc: Peter Maydell, Bastian Koppelmann, Stefan Weil

clang report:

target-tricore/op_helper.c:1247:24: warning:
  taking the absolute value of unsigned type 'uint32_t' (aka 'unsigned int')
  has no effect [-Wabsolute-value]
target-tricore/op_helper.c:1248:25: warning:
  taking the absolute value of unsigned type 'uint32_t' (aka 'unsigned int')
  has no effect [-Wabsolute-value]
target-tricore/op_helper.c:1249:19: warning:
  taking the absolute value of unsigned type 'uint32_t' (aka 'unsigned int')
  has no effect [-Wabsolute-value]
target-tricore/op_helper.c:1297:24: warning:
  taking the absolute value of unsigned type 'uint32_t' (aka 'unsigned int')
  has no effect [-Wabsolute-value]
target-tricore/op_helper.c:1298:25: warning:
  taking the absolute value of unsigned type 'uint32_t' (aka 'unsigned int')
  has no effect [-Wabsolute-value]
target-tricore/op_helper.c:1299:19: warning:
  taking the absolute value of unsigned type 'uint32_t' (aka 'unsigned int')
  has no effect [-Wabsolute-value]

Fix also the divisor which was taken from the wrong register
(thanks to Peter Maydell for this hint).

Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Signed-off-by: Stefan Weil <sw@weilnetz.de>
---

v2 adds the fix for the wrong register.

Stefan

 target-tricore/op_helper.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/target-tricore/op_helper.c b/target-tricore/op_helper.c
index ed26b30..52ad80b 100644
--- a/target-tricore/op_helper.c
+++ b/target-tricore/op_helper.c
@@ -1244,9 +1244,9 @@ uint64_t helper_dvinit_b_13(CPUTriCoreState *env, uint32_t r1, uint32_t r2)
         quotient_sign = 1;
     }
 
-    abs_sig_dividend = abs(r1) >> 7;
-    abs_base_dividend = abs(r1) & 0x7f;
-    abs_divisor = abs(r1);
+    abs_sig_dividend = abs((int32_t)r1) >> 7;
+    abs_base_dividend = abs((int32_t)r1) & 0x7f;
+    abs_divisor = abs((int32_t)r2);
     /* calc overflow */
     env->PSW_USB_V = 0;
     if ((quotient_sign) && (abs_divisor)) {
@@ -1294,9 +1294,9 @@ uint64_t helper_dvinit_h_13(CPUTriCoreState *env, uint32_t r1, uint32_t r2)
         quotient_sign = 1;
     }
 
-    abs_sig_dividend = abs(r1) >> 7;
-    abs_base_dividend = abs(r1) & 0x7f;
-    abs_divisor = abs(r1);
+    abs_sig_dividend = abs((int32_t)r1) >> 7;
+    abs_base_dividend = abs((int32_t)r1) & 0x7f;
+    abs_divisor = abs((int32_t)r2);
     /* calc overflow */
     env->PSW_USB_V = 0;
     if ((quotient_sign) && (abs_divisor)) {
-- 
2.1.4

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

* Re: [Qemu-devel] [PATCH v2] target-tricore: Fix two helper functions (clang warnings)
  2015-03-07 14:43 [Qemu-devel] [PATCH v2] target-tricore: Fix two helper functions (clang warnings) Stefan Weil
@ 2015-03-09 16:14 ` Bastian Koppelmann
  2015-03-23 14:41 ` Bastian Koppelmann
  1 sibling, 0 replies; 4+ messages in thread
From: Bastian Koppelmann @ 2015-03-09 16:14 UTC (permalink / raw)
  To: Stefan Weil, QEMU Developer; +Cc: Peter Maydell

Hi Stefan,

On 03/07/2015 02:43 PM, Stefan Weil wrote:
> clang report:
>
> target-tricore/op_helper.c:1247:24: warning:
>    taking the absolute value of unsigned type 'uint32_t' (aka 'unsigned int')
>    has no effect [-Wabsolute-value]
> target-tricore/op_helper.c:1248:25: warning:
>    taking the absolute value of unsigned type 'uint32_t' (aka 'unsigned int')
>    has no effect [-Wabsolute-value]
> target-tricore/op_helper.c:1249:19: warning:
>    taking the absolute value of unsigned type 'uint32_t' (aka 'unsigned int')
>    has no effect [-Wabsolute-value]
> target-tricore/op_helper.c:1297:24: warning:
>    taking the absolute value of unsigned type 'uint32_t' (aka 'unsigned int')
>    has no effect [-Wabsolute-value]
> target-tricore/op_helper.c:1298:25: warning:
>    taking the absolute value of unsigned type 'uint32_t' (aka 'unsigned int')
>    has no effect [-Wabsolute-value]
> target-tricore/op_helper.c:1299:19: warning:
>    taking the absolute value of unsigned type 'uint32_t' (aka 'unsigned int')
>    has no effect [-Wabsolute-value]
>
> Fix also the divisor which was taken from the wrong register
> (thanks to Peter Maydell for this hint).
>
> Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
>
> v2 adds the fix for the wrong register.
>
> Stefan
Thanks for the patch. It looks good to me so far. However I would like 
to test it on real hardware, to which I don't have access right now and 
might take about a week.

Cheers,
Bastian

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

* Re: [Qemu-devel] [PATCH v2] target-tricore: Fix two helper functions (clang warnings)
  2015-03-07 14:43 [Qemu-devel] [PATCH v2] target-tricore: Fix two helper functions (clang warnings) Stefan Weil
  2015-03-09 16:14 ` Bastian Koppelmann
@ 2015-03-23 14:41 ` Bastian Koppelmann
  2015-03-23 17:36   ` Bastian Koppelmann
  1 sibling, 1 reply; 4+ messages in thread
From: Bastian Koppelmann @ 2015-03-23 14:41 UTC (permalink / raw)
  To: Stefan Weil, QEMU Developer; +Cc: Peter Maydell

Hi Stefan,

On 03/07/2015 02:43 PM, Stefan Weil wrote:
> clang report:
>
> target-tricore/op_helper.c:1247:24: warning:
>    taking the absolute value of unsigned type 'uint32_t' (aka 'unsigned int')
>    has no effect [-Wabsolute-value]
> target-tricore/op_helper.c:1248:25: warning:
>    taking the absolute value of unsigned type 'uint32_t' (aka 'unsigned int')
>    has no effect [-Wabsolute-value]
> target-tricore/op_helper.c:1249:19: warning:
>    taking the absolute value of unsigned type 'uint32_t' (aka 'unsigned int')
>    has no effect [-Wabsolute-value]
> target-tricore/op_helper.c:1297:24: warning:
>    taking the absolute value of unsigned type 'uint32_t' (aka 'unsigned int')
>    has no effect [-Wabsolute-value]
> target-tricore/op_helper.c:1298:25: warning:
>    taking the absolute value of unsigned type 'uint32_t' (aka 'unsigned int')
>    has no effect [-Wabsolute-value]
> target-tricore/op_helper.c:1299:19: warning:
>    taking the absolute value of unsigned type 'uint32_t' (aka 'unsigned int')
>    has no effect [-Wabsolute-value]
>
> Fix also the divisor which was taken from the wrong register
> (thanks to Peter Maydell for this hint).
>
> Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
> [snip]

The code for dvinit.b and dvinit.h is not correctly calculating the 
overflow bit, but I can't figure out why, since the documentation of the 
real hardware seems to be wrong. I will take your patch for now, so the 
warning is gone and try to come up with a proper fix as soon as possible.

Cheers,
Bastian

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

* Re: [Qemu-devel] [PATCH v2] target-tricore: Fix two helper functions (clang warnings)
  2015-03-23 14:41 ` Bastian Koppelmann
@ 2015-03-23 17:36   ` Bastian Koppelmann
  0 siblings, 0 replies; 4+ messages in thread
From: Bastian Koppelmann @ 2015-03-23 17:36 UTC (permalink / raw)
  To: Stefan Weil, QEMU Developer; +Cc: Peter Maydell

Hi Stefan,

On 03/23/2015 03:41 PM, Bastian Koppelmann wrote:
> [snip]
>
> The code for dvinit.b and dvinit.h is not correctly calculating the 
> overflow bit, but I can't figure out why, since the documentation of 
> the real hardware seems to be wrong. I will take your patch for now, 
> so the warning is gone and try to come up with a proper fix as soon as 
> possible.
>
> Cheers,
> Bastian
>
I have the proper fix now and will send a patch to the list in a few 
minutes. I'll keep your patch and will apply the fix on top of it.

Cheers,
Bastian

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

end of thread, other threads:[~2015-03-23 16:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-07 14:43 [Qemu-devel] [PATCH v2] target-tricore: Fix two helper functions (clang warnings) Stefan Weil
2015-03-09 16:14 ` Bastian Koppelmann
2015-03-23 14:41 ` Bastian Koppelmann
2015-03-23 17:36   ` Bastian Koppelmann

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