* [PATCH] target/rx: Fix compiler errors for build with sanitizers
@ 2021-01-28 17:21 Stefan Weil
2021-01-28 17:49 ` Philippe Mathieu-Daudé
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Stefan Weil @ 2021-01-28 17:21 UTC (permalink / raw)
To: Yoshinori Sato
Cc: Philippe Mathieu-Daudé, Richard Henderson, qemu-devel, Stefan Weil
gcc (Debian 10.2.1-6) 10.2.1 20210110 aborts builds with enabled sanitizers:
../../../target/rx/op_helper.c: In function ‘helper_scmpu’:
../../../target/rx/op_helper.c:213:24: error: ‘tmp1’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
213 | env->psw_c = (tmp0 >= tmp1);
| ~~~~~~^~~~~~~~
../../../target/rx/op_helper.c:213:24: error: ‘tmp0’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
../../../target/rx/op_helper.c: In function ‘helper_suntil’:
../../../target/rx/op_helper.c:299:23: error: ‘tmp’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
299 | env->psw_c = (tmp <= env->regs[2]);
| ~~~~~^~~~~~~~~~~~~~~~
../../../target/rx/op_helper.c: In function ‘helper_swhile’:
../../../target/rx/op_helper.c:318:23: error: ‘tmp’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
318 | env->psw_c = (tmp <= env->regs[2]);
| ~~~~~^~~~~~~~~~~~~~~~
Rewriting the code fixes those errors.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
Those error are false positives, but simple code changes help the
compiler (and perhaps reviewers) to understand it better.
Stefan
target/rx/op_helper.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/target/rx/op_helper.c b/target/rx/op_helper.c
index 59389f4992..4d315b4449 100644
--- a/target/rx/op_helper.c
+++ b/target/rx/op_helper.c
@@ -201,14 +201,14 @@ void helper_scmpu(CPURXState *env)
if (env->regs[3] == 0) {
return;
}
- while (env->regs[3] != 0) {
+ do {
tmp0 = cpu_ldub_data_ra(env, env->regs[1]++, GETPC());
tmp1 = cpu_ldub_data_ra(env, env->regs[2]++, GETPC());
env->regs[3]--;
if (tmp0 != tmp1 || tmp0 == '\0') {
break;
}
- }
+ } while (env->regs[3] != 0);
env->psw_z = tmp0 - tmp1;
env->psw_c = (tmp0 >= tmp1);
}
@@ -287,14 +287,14 @@ void helper_suntil(CPURXState *env, uint32_t sz)
if (env->regs[3] == 0) {
return ;
}
- while (env->regs[3] != 0) {
+ do {
tmp = cpu_ldufn[sz](env, env->regs[1], GETPC());
env->regs[1] += 1 << sz;
env->regs[3]--;
if (tmp == env->regs[2]) {
break;
}
- }
+ } while (env->regs[3] != 0);
env->psw_z = tmp - env->regs[2];
env->psw_c = (tmp <= env->regs[2]);
}
@@ -306,14 +306,14 @@ void helper_swhile(CPURXState *env, uint32_t sz)
if (env->regs[3] == 0) {
return ;
}
- while (env->regs[3] != 0) {
+ do {
tmp = cpu_ldufn[sz](env, env->regs[1], GETPC());
env->regs[1] += 1 << sz;
env->regs[3]--;
if (tmp != env->regs[2]) {
break;
}
- }
+ } while (env->regs[3] != 0);
env->psw_z = env->regs[3];
env->psw_c = (tmp <= env->regs[2]);
}
--
2.24.3 (Apple Git-128)
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] target/rx: Fix compiler errors for build with sanitizers
2021-01-28 17:21 [PATCH] target/rx: Fix compiler errors for build with sanitizers Stefan Weil
@ 2021-01-28 17:49 ` Philippe Mathieu-Daudé
2021-01-28 18:04 ` Philippe Mathieu-Daudé
2021-01-29 6:13 ` Thomas Huth
2021-01-29 7:57 ` Laurent Vivier
2 siblings, 1 reply; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-01-28 17:49 UTC (permalink / raw)
To: Stefan Weil, Yoshinori Sato; +Cc: Richard Henderson, qemu-devel
On 1/28/21 6:21 PM, Stefan Weil wrote:
> gcc (Debian 10.2.1-6) 10.2.1 20210110 aborts builds with enabled sanitizers:
>
> ../../../target/rx/op_helper.c: In function ‘helper_scmpu’:
> ../../../target/rx/op_helper.c:213:24: error: ‘tmp1’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 213 | env->psw_c = (tmp0 >= tmp1);
> | ~~~~~~^~~~~~~~
> ../../../target/rx/op_helper.c:213:24: error: ‘tmp0’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> ../../../target/rx/op_helper.c: In function ‘helper_suntil’:
> ../../../target/rx/op_helper.c:299:23: error: ‘tmp’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 299 | env->psw_c = (tmp <= env->regs[2]);
> | ~~~~~^~~~~~~~~~~~~~~~
> ../../../target/rx/op_helper.c: In function ‘helper_swhile’:
> ../../../target/rx/op_helper.c:318:23: error: ‘tmp’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 318 | env->psw_c = (tmp <= env->regs[2]);
> | ~~~~~^~~~~~~~~~~~~~~~
>
> Rewriting the code fixes those errors.
>
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
>
> Those error are false positives, but simple code changes help the
> compiler (and perhaps reviewers) to understand it better.
>
> Stefan
>
>
> target/rx/op_helper.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] target/rx: Fix compiler errors for build with sanitizers
2021-01-28 17:49 ` Philippe Mathieu-Daudé
@ 2021-01-28 18:04 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-01-28 18:04 UTC (permalink / raw)
To: Stefan Weil, Yoshinori Sato; +Cc: QEMU Trivial, Richard Henderson, qemu-devel
+qemu-trivial@
On 1/28/21 6:49 PM, Philippe Mathieu-Daudé wrote:
> On 1/28/21 6:21 PM, Stefan Weil wrote:
>> gcc (Debian 10.2.1-6) 10.2.1 20210110 aborts builds with enabled sanitizers:
>>
>> ../../../target/rx/op_helper.c: In function ‘helper_scmpu’:
>> ../../../target/rx/op_helper.c:213:24: error: ‘tmp1’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>> 213 | env->psw_c = (tmp0 >= tmp1);
>> | ~~~~~~^~~~~~~~
>> ../../../target/rx/op_helper.c:213:24: error: ‘tmp0’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>> ../../../target/rx/op_helper.c: In function ‘helper_suntil’:
>> ../../../target/rx/op_helper.c:299:23: error: ‘tmp’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>> 299 | env->psw_c = (tmp <= env->regs[2]);
>> | ~~~~~^~~~~~~~~~~~~~~~
>> ../../../target/rx/op_helper.c: In function ‘helper_swhile’:
>> ../../../target/rx/op_helper.c:318:23: error: ‘tmp’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>> 318 | env->psw_c = (tmp <= env->regs[2]);
>> | ~~~~~^~~~~~~~~~~~~~~~
>>
>> Rewriting the code fixes those errors.
>>
>> Signed-off-by: Stefan Weil <sw@weilnetz.de>
>> ---
>>
>> Those error are false positives, but simple code changes help the
>> compiler (and perhaps reviewers) to understand it better.
>>
>> Stefan
>>
>>
>> target/rx/op_helper.c | 12 ++++++------
>> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] target/rx: Fix compiler errors for build with sanitizers
2021-01-28 17:21 [PATCH] target/rx: Fix compiler errors for build with sanitizers Stefan Weil
2021-01-28 17:49 ` Philippe Mathieu-Daudé
@ 2021-01-29 6:13 ` Thomas Huth
2021-01-29 7:57 ` Laurent Vivier
2 siblings, 0 replies; 5+ messages in thread
From: Thomas Huth @ 2021-01-29 6:13 UTC (permalink / raw)
To: Stefan Weil, Yoshinori Sato
Cc: QEMU Trivial, Richard Henderson, Philippe Mathieu-Daudé, qemu-devel
On 28/01/2021 18.21, Stefan Weil wrote:
> gcc (Debian 10.2.1-6) 10.2.1 20210110 aborts builds with enabled sanitizers:
>
> ../../../target/rx/op_helper.c: In function ‘helper_scmpu’:
> ../../../target/rx/op_helper.c:213:24: error: ‘tmp1’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 213 | env->psw_c = (tmp0 >= tmp1);
> | ~~~~~~^~~~~~~~
> ../../../target/rx/op_helper.c:213:24: error: ‘tmp0’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> ../../../target/rx/op_helper.c: In function ‘helper_suntil’:
> ../../../target/rx/op_helper.c:299:23: error: ‘tmp’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 299 | env->psw_c = (tmp <= env->regs[2]);
> | ~~~~~^~~~~~~~~~~~~~~~
> ../../../target/rx/op_helper.c: In function ‘helper_swhile’:
> ../../../target/rx/op_helper.c:318:23: error: ‘tmp’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 318 | env->psw_c = (tmp <= env->regs[2]);
> | ~~~~~^~~~~~~~~~~~~~~~
>
> Rewriting the code fixes those errors.
>
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
>
> Those error are false positives, but simple code changes help the
> compiler (and perhaps reviewers) to understand it better.
>
> Stefan
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] target/rx: Fix compiler errors for build with sanitizers
2021-01-28 17:21 [PATCH] target/rx: Fix compiler errors for build with sanitizers Stefan Weil
2021-01-28 17:49 ` Philippe Mathieu-Daudé
2021-01-29 6:13 ` Thomas Huth
@ 2021-01-29 7:57 ` Laurent Vivier
2 siblings, 0 replies; 5+ messages in thread
From: Laurent Vivier @ 2021-01-29 7:57 UTC (permalink / raw)
To: Stefan Weil, Yoshinori Sato
Cc: qemu-trivial, Richard Henderson, Philippe Mathieu-Daudé, qemu-devel
Le 28/01/2021 à 18:21, Stefan Weil a écrit :
> gcc (Debian 10.2.1-6) 10.2.1 20210110 aborts builds with enabled sanitizers:
>
> ../../../target/rx/op_helper.c: In function ‘helper_scmpu’:
> ../../../target/rx/op_helper.c:213:24: error: ‘tmp1’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 213 | env->psw_c = (tmp0 >= tmp1);
> | ~~~~~~^~~~~~~~
> ../../../target/rx/op_helper.c:213:24: error: ‘tmp0’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> ../../../target/rx/op_helper.c: In function ‘helper_suntil’:
> ../../../target/rx/op_helper.c:299:23: error: ‘tmp’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 299 | env->psw_c = (tmp <= env->regs[2]);
> | ~~~~~^~~~~~~~~~~~~~~~
> ../../../target/rx/op_helper.c: In function ‘helper_swhile’:
> ../../../target/rx/op_helper.c:318:23: error: ‘tmp’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 318 | env->psw_c = (tmp <= env->regs[2]);
> | ~~~~~^~~~~~~~~~~~~~~~
>
> Rewriting the code fixes those errors.
>
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
>
> Those error are false positives, but simple code changes help the
> compiler (and perhaps reviewers) to understand it better.
>
> Stefan
>
>
> target/rx/op_helper.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/target/rx/op_helper.c b/target/rx/op_helper.c
> index 59389f4992..4d315b4449 100644
> --- a/target/rx/op_helper.c
> +++ b/target/rx/op_helper.c
> @@ -201,14 +201,14 @@ void helper_scmpu(CPURXState *env)
> if (env->regs[3] == 0) {
> return;
> }
> - while (env->regs[3] != 0) {
> + do {
> tmp0 = cpu_ldub_data_ra(env, env->regs[1]++, GETPC());
> tmp1 = cpu_ldub_data_ra(env, env->regs[2]++, GETPC());
> env->regs[3]--;
> if (tmp0 != tmp1 || tmp0 == '\0') {
> break;
> }
> - }
> + } while (env->regs[3] != 0);
> env->psw_z = tmp0 - tmp1;
> env->psw_c = (tmp0 >= tmp1);
> }
> @@ -287,14 +287,14 @@ void helper_suntil(CPURXState *env, uint32_t sz)
> if (env->regs[3] == 0) {
> return ;
> }
> - while (env->regs[3] != 0) {
> + do {
> tmp = cpu_ldufn[sz](env, env->regs[1], GETPC());
> env->regs[1] += 1 << sz;
> env->regs[3]--;
> if (tmp == env->regs[2]) {
> break;
> }
> - }
> + } while (env->regs[3] != 0);
> env->psw_z = tmp - env->regs[2];
> env->psw_c = (tmp <= env->regs[2]);
> }
> @@ -306,14 +306,14 @@ void helper_swhile(CPURXState *env, uint32_t sz)
> if (env->regs[3] == 0) {
> return ;
> }
> - while (env->regs[3] != 0) {
> + do {
> tmp = cpu_ldufn[sz](env, env->regs[1], GETPC());
> env->regs[1] += 1 << sz;
> env->regs[3]--;
> if (tmp != env->regs[2]) {
> break;
> }
> - }
> + } while (env->regs[3] != 0);
> env->psw_z = env->regs[3];
> env->psw_c = (tmp <= env->regs[2]);
> }
>
Applied to my trivial-patches branch.
Thanks,
Laurent
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-01-29 7:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-28 17:21 [PATCH] target/rx: Fix compiler errors for build with sanitizers Stefan Weil
2021-01-28 17:49 ` Philippe Mathieu-Daudé
2021-01-28 18:04 ` Philippe Mathieu-Daudé
2021-01-29 6:13 ` Thomas Huth
2021-01-29 7:57 ` Laurent Vivier
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).