target/rx: Fix compiler errors for build with sanitizers
PATCH 1/1 target/rx: Fix compiler errors for build with sanitizers
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.
---
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(-)
target/rx/op_helper.c +6 -6
@@ -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 ]); }
Signature · 1 line
2.24.3 (Apple Git-128)
Quoted 21 lines · 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 <[email protected]>---
Quoted 8 lines
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(-)
+qemu-trivial@
Quoted 33 lines · Philippe Mathieu-Daudé
Quoted 21 lines · 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 <[email protected]>---
Quoted 8 lines
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é <[email protected]>
Quoted 18 lines · 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.
Quoted 7 lines
Signed-off-by Stefan Weil <[email protected]>---
Those error are false positives, but simple code changes help the compiler (and perhaps reviewers) to understand it better.
Stefan
Laurent Vivier
AppliedLe 28/01/2021 à 18:21, Stefan Weil a écrit :
Quoted 76 lines
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 <[email protected]>---
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(-)target/rx/op_helper.c +5
-5@@ -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());
target/rx/op_helper.c void helper_swhile(CPURXState *env, uint32_t sz) · line 319
Quoted 10 lines
target/rx/op_helper.c +1
-1env->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