Skip to contentSkip to conversation

silence the compiler warnings

PATCH Superseded Chen Qun 8 participants 40 messages Oct 28, 2020 – Oct 29, 2020

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Chen Qun

author
#0 lore raw

cover silence the compiler warnings

Hi all,

When building with GCC9 using CFLAG -Wimplicit-fallthrough=2 we get a lot of warning. Some problems may be missing break statements which I have submitted the patch separately.

This series is all add the corresponding "fall through" comment to fix them.

Chen Qun (9):
target/i386: silence the compiler warnings in gen_shiftd_rm_T1 hw/intc/arm_gicv3_kvm: silence the compiler warnings accel/tcg/user-exec: silence the compiler warnings linux-user/mips/cpu_loop: silence the compiler warnings target/sparc/translate: silence the compiler warnings target/sparc/win_helper: silence the compiler warnings
ppc: silence the compiler warnings
target/ppc: silence the compiler warnings hw/timer/renesas_tmr: silence the compiler warnings

 accel/tcg/user-exec.c      | 2 +-
 hw/intc/arm_gicv3_kvm.c    | 8 ++++++++
 hw/ppc/ppc.c               | 1 +
 hw/timer/renesas_tmr.c     | 1 +
 linux-user/mips/cpu_loop.c | 4 ++++
 target/i386/translate.c    | 4 ++--
 target/ppc/mmu_helper.c    | 1 +
 target/sparc/translate.c   | 2 +-
 target/sparc/win_helper.c  | 1 +
 9 files changed, 20 insertions(+), 4 deletions(-)
Signature · 1 line
2.27.0
author
#1 lore raw

PATCH 1/9 target/i386: silence the compiler warnings in gen_shiftd_rm_T1

The current "#ifdef TARGET_X86_64" statement affects the compiler's determination of fall through.

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
target/i386/translate.c: In function ‘gen_shiftd_rm_T1’:
target/i386/translate.c:1773:12: warning: this statement may fall through [-Wimplicit-fallthrough=]

         if (is_right) {
            ^
target/i386/translate.c:1782:5: note: here
     case MO_32:
     ^~~~

---
Cc: Paolo Bonzini <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Eduardo Habkost <[email protected]>

---
 target/i386/translate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/i386/translate.c +2 -2
index caea6f5fb1..4c353427d7 100644
@@ -1777,9 +1777,9 @@ static void gen_shiftd_rm_T1(DisasContext *s, MemOp ot, int op1,
         } else {
             tcg_gen_deposit_tl(s->T1, s->T0, s->T1, 16, 16);
         }
-        /* FALLTHRU */
-#ifdef TARGET_X86_64
+        /* fall through */
     case MO_32:
+#ifdef TARGET_X86_64
         /* Concatenate the two 32-bit values and use a 64-bit shift.  */
         tcg_gen_subi_tl(s->tmp0, count, 1);
         if (is_right) {
Signature · 1 line
2.27.0
#2 lore raw

Re: [PATCH 1/9] target/i386: silence the compiler warnings in gen_shiftd_rm_T1

Quoted 28 lines · Chen Qun

The current "#ifdef TARGET_X86_64" statement affects the compiler's determination of fall through.

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
target/i386/translate.c: In function ‘gen_shiftd_rm_T1’:
target/i386/translate.c:1773:12: warning: this statement may fall through [-Wimplicit-fallthrough=]

         if (is_right) {
            ^
target/i386/translate.c:1782:5: note: here
     case MO_32:
     ^~~~

---
Cc: Paolo Bonzini <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Eduardo Habkost <[email protected]>

---
 target/i386/translate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/i386/translate.c +0 -0
index caea6f5fb1..4c353427d7 100644
@@ -1777,9 +1777,9 @@ static void gen_shiftd_rm_T1(DisasContext *s, MemOp ot, int op1,
         } else {

target/i386/translate.c static void gen_shiftd_rm_T1(DisasContext *s, MemOp ot, int op1, · line 1785

Quoted 10 lines
target/i386/translate.c +2 -2
             tcg_gen_deposit_tl(s->T1, s->T0, s->T1, 16, 16);
         }
-        /* FALLTHRU */
-#ifdef TARGET_X86_64
+        /* fall through */
     case MO_32:
+#ifdef TARGET_X86_64
         /* Concatenate the two 32-bit values and use a 64-bit shift.  */
         tcg_gen_subi_tl(s->tmp0, count, 1);
         if (is_right) {

The whole code here looks a little bit fishy to me ... in case TARGET_X86_64 is defined, the MO_16 code falls through to MO_32 ... but in case it is not defined, it falls through to the default case that comes after the #ifdef block? Is this really the right thing here? If so, I think there should be some additional comments explaining this behavior.

Richard, maybe you could help to judge what is right here...?

Thomas

#3 lore raw

Re: [PATCH 1/9] target/i386: silence the compiler warnings in gen_shiftd_rm_T1

+Tony

Quoted 46 lines · Thomas Huth
Quoted 28 lines · Chen Qun

The current "#ifdef TARGET_X86_64" statement affects the compiler's determination of fall through.

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
target/i386/translate.c: In function ‘gen_shiftd_rm_T1’:
target/i386/translate.c:1773:12: warning: this statement may fall through [-Wimplicit-fallthrough=]

         if (is_right) {
            ^
target/i386/translate.c:1782:5: note: here
     case MO_32:
     ^~~~

---
Cc: Paolo Bonzini <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Eduardo Habkost <[email protected]>

---
 target/i386/translate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/i386/translate.c +0 -0
index caea6f5fb1..4c353427d7 100644
@@ -1777,9 +1777,9 @@ static void gen_shiftd_rm_T1(DisasContext *s, MemOp ot, int op1,
         } else {

target/i386/translate.c static void gen_shiftd_rm_T1(DisasContext *s, MemOp ot, int op1, · line 1785

Quoted 10 lines
target/i386/translate.c +2 -2
             tcg_gen_deposit_tl(s->T1, s->T0, s->T1, 16, 16);
         }
-        /* FALLTHRU */
-#ifdef TARGET_X86_64
+        /* fall through */
     case MO_32:
+#ifdef TARGET_X86_64
         /* Concatenate the two 32-bit values and use a 64-bit shift.  */
         tcg_gen_subi_tl(s->tmp0, count, 1);
         if (is_right) {

The whole code here looks a little bit fishy to me ... in case TARGET_X86_64 is defined, the MO_16 code falls through to MO_32 ... but in case it is not defined, it falls through to the default case that comes after the #ifdef block? Is this really the right thing here? If so, I think there should be some additional comments explaining this behavior.

Quoted 1 line

Richard, maybe you could help to judge what is right here...?

I think the previous discussion is this thread:
https://www.mail-archive.com/[email protected]/msg632245.html

#4 lore raw

Re: [PATCH 1/9] target/i386: silence the compiler warnings in gen_shiftd_rm_T1

In reply to Thomas Huth
Quoted 46 lines · Thomas Huth
Quoted 28 lines · Chen Qun

The current "#ifdef TARGET_X86_64" statement affects the compiler's determination of fall through.

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
target/i386/translate.c: In function ‘gen_shiftd_rm_T1’:
target/i386/translate.c:1773:12: warning: this statement may fall through [-Wimplicit-fallthrough=]

         if (is_right) {
            ^
target/i386/translate.c:1782:5: note: here
     case MO_32:
     ^~~~

---
Cc: Paolo Bonzini <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Eduardo Habkost <[email protected]>

---
 target/i386/translate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/i386/translate.c +0 -0
index caea6f5fb1..4c353427d7 100644
@@ -1777,9 +1777,9 @@ static void gen_shiftd_rm_T1(DisasContext *s, MemOp ot, int op1,
         } else {

target/i386/translate.c static void gen_shiftd_rm_T1(DisasContext *s, MemOp ot, int op1, · line 1785

Quoted 10 lines
target/i386/translate.c +2 -2
             tcg_gen_deposit_tl(s->T1, s->T0, s->T1, 16, 16);
         }
-        /* FALLTHRU */
-#ifdef TARGET_X86_64
+        /* fall through */
     case MO_32:
+#ifdef TARGET_X86_64
         /* Concatenate the two 32-bit values and use a 64-bit shift.  */
         tcg_gen_subi_tl(s->tmp0, count, 1);
         if (is_right) {

The whole code here looks a little bit fishy to me ... in case TARGET_X86_64 is defined, the MO_16 code falls through to MO_32 ... but in case it is not defined, it falls through to the default case that comes after the #ifdef block? Is this really the right thing here? If so, I think there should be some additional comments explaining this behavior.

Quoted 1 line

Richard, maybe you could help to judge what is right here...?

It could definitely be rewritten, but it's not wrong as is.

r~

Reviewed-by
#5 lore raw

Re: [PATCH 1/9] target/i386: silence the compiler warnings in gen_shiftd_rm_T1

Quoted 47 lines · Richard Henderson
Quoted 46 lines · Thomas Huth
Quoted 28 lines · Chen Qun

The current "#ifdef TARGET_X86_64" statement affects the compiler's determination of fall through.

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
target/i386/translate.c: In function ‘gen_shiftd_rm_T1’:
target/i386/translate.c:1773:12: warning: this statement may fall through [-Wimplicit-fallthrough=]

         if (is_right) {
            ^
target/i386/translate.c:1782:5: note: here
     case MO_32:
     ^~~~

---
Cc: Paolo Bonzini <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Eduardo Habkost <[email protected]>

---
 target/i386/translate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/i386/translate.c +0 -0
index caea6f5fb1..4c353427d7 100644
@@ -1777,9 +1777,9 @@ static void gen_shiftd_rm_T1(DisasContext *s, MemOp ot, int op1,
         } else {

target/i386/translate.c static void gen_shiftd_rm_T1(DisasContext *s, MemOp ot, int op1, · line 1785

Quoted 10 lines
target/i386/translate.c +2 -2
             tcg_gen_deposit_tl(s->T1, s->T0, s->T1, 16, 16);
         }
-        /* FALLTHRU */
-#ifdef TARGET_X86_64
+        /* fall through */
     case MO_32:
+#ifdef TARGET_X86_64
         /* Concatenate the two 32-bit values and use a 64-bit shift.  */
         tcg_gen_subi_tl(s->tmp0, count, 1);
         if (is_right) {

The whole code here looks a little bit fishy to me ... in case TARGET_X86_64 is defined, the MO_16 code falls through to MO_32 ... but in case it is not defined, it falls through to the default case that comes after the #ifdef block? Is this really the right thing here? If so, I think there should be some additional comments explaining this behavior.

Quoted 3 lines
Quoted 1 line

Richard, maybe you could help to judge what is right here...?

It could definitely be rewritten, but it's not wrong as is.

Ok, thanks for the clarification! In that case:

#6 lore raw

RE: [PATCH 1/9] target/i386: silence the compiler warnings in gen_shiftd_rm_T1

Quoted 66 lines

-----Original Message-----
From: Thomas Huth [mailto:[email protected]]
Sent: Thursday, October 29, 2020 12:52 AM
To: Richard Henderson <[email protected]>; Chenqun (kuhn) <[email protected]>; [email protected]; [email protected]
Cc: Eduardo Habkost <[email protected]>; Zhanghailiang <[email protected]>; ganqixin <[email protected]>; Euler Robot <[email protected]>; Paolo Bonzini <[email protected]>; Richard Henderson <[email protected]>
Subject: Re: [PATCH 1/9] target/i386: silence the compiler warnings in gen_shiftd_rm_T1

Quoted 6 lines · Richard Henderson
Quoted 5 lines · Thomas Huth
Quoted 4 lines · Chen Qun

The current "#ifdef TARGET_X86_64" statement affects the compiler's determination of fall through.

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed

warning:

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

target/i386/translate.c: In function ‘gen_shiftd_rm_T1’:
target/i386/translate.c:1773:12: warning: this statement may fall through

[-Wimplicit-fallthrough=]

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
         if (is_right) {
            ^
target/i386/translate.c:1782:5: note: here
     case MO_32:
     ^~~~

---
Cc: Paolo Bonzini <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Eduardo Habkost <[email protected]>

---
 target/i386/translate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 5 lines
Quoted 5 lines

target/i386/translate.c static void gen_shiftd_rm_T1(DisasContext *s,

Quoted 5 lines
target/i386/translate.c index renamed from target/i386/translate.c +0 -0

caea6f5fb1..4c353427d7 100644

target/i386/translate.c +0 -0
@@ -1777,9 +1777,9 @@ static void gen_shiftd_rm_T1(DisasContext *s,

MemOp ot, int op1,

Quoted 9 lines
Quoted 9 lines

target/i386/translate.c static void gen_shiftd_rm_T1(DisasContext *s, MemOp ot, int op1,

Quoted 9 lines
target/i386/translate.c +2 -2
         } else {
             tcg_gen_deposit_tl(s->T1, s->T0, s->T1, 16, 16);
         }
-        /* FALLTHRU */
-#ifdef TARGET_X86_64
+        /* fall through */
     case MO_32:
+#ifdef TARGET_X86_64
         /* Concatenate the two 32-bit values and use a 64-bit shift.

*/

Quoted 8 lines
Quoted 8 lines

target/i386/translate.c static void gen_shiftd_rm_T1(DisasContext *s, MemOp ot, int op1, · line 1785

Quoted 2 lines
target/i386/translate.c +0 -0
         tcg_gen_subi_tl(s->tmp0, count, 1);
         if (is_right) {

The whole code here looks a little bit fishy to me ... in case TARGET_X86_64 is defined, the MO_16 code falls through to MO_32 ... but in case it is not defined, it falls through to the default case that comes after the #ifdef block? Is this really the right thing here? If so, I think there should be some additional comments explaining

this behavior.

Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Richard, maybe you could help to judge what is right here...?

It could definitely be rewritten, but it's not wrong as is.

Ok, thanks for the clarification! In that case:

Thanks for the discussion!
I might add a little comment to describe this behavior base on this patch.
Just like: /* If TARGET_X86_64 defined then fall through into MO_32, otherwise fall through default. */

If there is no other suggestion, I'll keep Richard's and Thomas 's "Reviewed-by" tag.

Thanks,
Chen Qun

Reviewed-by on v1 1/9
#7 lore raw

Re: [PATCH 1/9] target/i386: silence the compiler warnings in gen_shiftd_rm_T1

In reply to Chen Qun
Quoted 27 lines · Chen Qun

The current "#ifdef TARGET_X86_64" statement affects the compiler's determination of fall through.

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
target/i386/translate.c: In function ‘gen_shiftd_rm_T1’:
target/i386/translate.c:1773:12: warning: this statement may fall through [-Wimplicit-fallthrough=]

         if (is_right) {
            ^
target/i386/translate.c:1782:5: note: here
     case MO_32:
     ^~~~

---
Cc: Paolo Bonzini <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Eduardo Habkost <[email protected]>

---
 target/i386/translate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/i386/translate.c +0 -0
index caea6f5fb1..4c353427d7 100644

target/i386/translate.c static void gen_shiftd_rm_T1(DisasContext *s, MemOp ot, int op1, · line 1783

Quoted 9 lines
target/i386/translate.c +2 -2
@@ -1777,9 +1777,9 @@ static void gen_shiftd_rm_T1(DisasContext *s, MemOp ot, int op1,
         } else {
             tcg_gen_deposit_tl(s->T1, s->T0, s->T1, 16, 16);
         }
-        /* FALLTHRU */
-#ifdef TARGET_X86_64
+        /* fall through */
     case MO_32:
+#ifdef TARGET_X86_64
         /* Concatenate the two 32-bit values and use a 64-bit shift.  *

r~

author
#8 lore raw

PATCH 2/9 hw/intc/arm_gicv3_kvm: silence the compiler warnings

In reply to Chen Qun

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
hw/intc/arm_gicv3_kvm.c: In function ‘kvm_arm_gicv3_put’:
hw/intc/arm_gicv3_kvm.c:484:13: warning: this statement may fall through [-Wimplicit-fallthrough=]

             kvm_gicc_access(s, ICC_AP0R_EL1(1), ncpu, &reg64, true);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hw/intc/arm_gicv3_kvm.c:485:9: note: here
         default:
         ^~~~~~~
hw/intc/arm_gicv3_kvm.c:495:13: warning: this statement may fall through [-Wimplicit-fallthrough=]
             kvm_gicc_access(s, ICC_AP1R_EL1(2), ncpu, &reg64, true);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hw/intc/arm_gicv3_kvm.c:496:9: note: here
         case 6:
         ^~~~
hw/intc/arm_gicv3_kvm.c:498:13: warning: this statement may fall through [-Wimplicit-fallthrough=]
             kvm_gicc_access(s, ICC_AP1R_EL1(1), ncpu, &reg64, true);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hw/intc/arm_gicv3_kvm.c:499:9: note: here
         default:
         ^~~~~~~

hw/intc/arm_gicv3_kvm.c: In function ‘kvm_arm_gicv3_get’:
hw/intc/arm_gicv3_kvm.c:634:37: warning: this statement may fall through [-Wimplicit-fallthrough=]

             c->icc_apr[GICV3_G0][2] = reg64;
             ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
hw/intc/arm_gicv3_kvm.c:635:9: note: here
         case 6:
         ^~~~
hw/intc/arm_gicv3_kvm.c:637:37: warning: this statement may fall through [-Wimplicit-fallthrough=]
             c->icc_apr[GICV3_G0][1] = reg64;
             ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
hw/intc/arm_gicv3_kvm.c:638:9: note: here
         default:
         ^~~~~~~
hw/intc/arm_gicv3_kvm.c:648:39: warning: this statement may fall through [-Wimplicit-fallthrough=]
             c->icc_apr[GICV3_G1NS][2] = reg64;
             ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
hw/intc/arm_gicv3_kvm.c:649:9: note: here
         case 6:
         ^~~~
hw/intc/arm_gicv3_kvm.c:651:39: warning: this statement may fall through [-Wimplicit-fallthrough=]
             c->icc_apr[GICV3_G1NS][1] = reg64;
             ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
hw/intc/arm_gicv3_kvm.c:652:9: note: here
         default:
         ^~~~~~~

---
Cc: Peter Maydell <[email protected]>
Cc: [email protected]

---
 hw/intc/arm_gicv3_kvm.c | 8 ++++++++
 1 file changed, 8 insertions(+)
hw/intc/arm_gicv3_kvm.c +8 -0
index 187eb054e0..d040a5d1e9 100644
@@ -478,9 +478,11 @@ static void kvm_arm_gicv3_put(GICv3State *s)
             kvm_gicc_access(s, ICC_AP0R_EL1(3), ncpu, &reg64, true);
             reg64 = c->icc_apr[GICV3_G0][2];
             kvm_gicc_access(s, ICC_AP0R_EL1(2), ncpu, &reg64, true);
+            /* fall through */
         case 6:
             reg64 = c->icc_apr[GICV3_G0][1];
             kvm_gicc_access(s, ICC_AP0R_EL1(1), ncpu, &reg64, true);
+            /* fall through */
         default:
             reg64 = c->icc_apr[GICV3_G0][0];
             kvm_gicc_access(s, ICC_AP0R_EL1(0), ncpu, &reg64, true);
@@ -492,9 +494,11 @@ static void kvm_arm_gicv3_put(GICv3State *s)
             kvm_gicc_access(s, ICC_AP1R_EL1(3), ncpu, &reg64, true);
             reg64 = c->icc_apr[GICV3_G1NS][2];
             kvm_gicc_access(s, ICC_AP1R_EL1(2), ncpu, &reg64, true);
+            /* fall through */
         case 6:
             reg64 = c->icc_apr[GICV3_G1NS][1];
             kvm_gicc_access(s, ICC_AP1R_EL1(1), ncpu, &reg64, true);
+            /* fall through */
         default:
             reg64 = c->icc_apr[GICV3_G1NS][0];
             kvm_gicc_access(s, ICC_AP1R_EL1(0), ncpu, &reg64, true);
@@ -631,9 +635,11 @@ static void kvm_arm_gicv3_get(GICv3State *s)
             c->icc_apr[GICV3_G0][3] = reg64;
             kvm_gicc_access(s, ICC_AP0R_EL1(2), ncpu, &reg64, false);
             c->icc_apr[GICV3_G0][2] = reg64;
+            /* fall through */
         case 6:
             kvm_gicc_access(s, ICC_AP0R_EL1(1), ncpu, &reg64, false);
             c->icc_apr[GICV3_G0][1] = reg64;
+            /* fall through */
         default:
             kvm_gicc_access(s, ICC_AP0R_EL1(0), ncpu, &reg64, false);
             c->icc_apr[GICV3_G0][0] = reg64;
@@ -645,9 +651,11 @@ static void kvm_arm_gicv3_get(GICv3State *s)
             c->icc_apr[GICV3_G1NS][3] = reg64;
             kvm_gicc_access(s, ICC_AP1R_EL1(2), ncpu, &reg64, false);
             c->icc_apr[GICV3_G1NS][2] = reg64;
+            /* fall through */
         case 6:
             kvm_gicc_access(s, ICC_AP1R_EL1(1), ncpu, &reg64, false);
             c->icc_apr[GICV3_G1NS][1] = reg64;
+            /* fall through */
         default:
             kvm_gicc_access(s, ICC_AP1R_EL1(0), ncpu, &reg64, false);
             c->icc_apr[GICV3_G1NS][0] = reg64;
Signature · 1 line
2.27.0
Reviewed-by on v1 2/9
#9 lore raw

Re: [PATCH 2/9] hw/intc/arm_gicv3_kvm: silence the compiler warnings

Quoted 48 lines · Chen Qun

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
hw/intc/arm_gicv3_kvm.c: In function ‘kvm_arm_gicv3_put’:
hw/intc/arm_gicv3_kvm.c:484:13: warning: this statement may fall through [-Wimplicit-fallthrough=]

             kvm_gicc_access(s, ICC_AP0R_EL1(1), ncpu, &reg64, true);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hw/intc/arm_gicv3_kvm.c:485:9: note: here
         default:
         ^~~~~~~
hw/intc/arm_gicv3_kvm.c:495:13: warning: this statement may fall through [-Wimplicit-fallthrough=]
             kvm_gicc_access(s, ICC_AP1R_EL1(2), ncpu, &reg64, true);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hw/intc/arm_gicv3_kvm.c:496:9: note: here
         case 6:
         ^~~~
hw/intc/arm_gicv3_kvm.c:498:13: warning: this statement may fall through [-Wimplicit-fallthrough=]
             kvm_gicc_access(s, ICC_AP1R_EL1(1), ncpu, &reg64, true);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hw/intc/arm_gicv3_kvm.c:499:9: note: here
         default:
         ^~~~~~~

hw/intc/arm_gicv3_kvm.c: In function ‘kvm_arm_gicv3_get’:
hw/intc/arm_gicv3_kvm.c:634:37: warning: this statement may fall through [-Wimplicit-fallthrough=]

             c->icc_apr[GICV3_G0][2] = reg64;
             ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
hw/intc/arm_gicv3_kvm.c:635:9: note: here
         case 6:
         ^~~~
hw/intc/arm_gicv3_kvm.c:637:37: warning: this statement may fall through [-Wimplicit-fallthrough=]
             c->icc_apr[GICV3_G0][1] = reg64;
             ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
hw/intc/arm_gicv3_kvm.c:638:9: note: here
         default:
         ^~~~~~~
hw/intc/arm_gicv3_kvm.c:648:39: warning: this statement may fall through [-Wimplicit-fallthrough=]
             c->icc_apr[GICV3_G1NS][2] = reg64;
             ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
hw/intc/arm_gicv3_kvm.c:649:9: note: here
         case 6:
         ^~~~
hw/intc/arm_gicv3_kvm.c:651:39: warning: this statement may fall through [-Wimplicit-fallthrough=]
             c->icc_apr[GICV3_G1NS][1] = reg64;
             ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
hw/intc/arm_gicv3_kvm.c:652:9: note: here
         default:
         ^~~~~~~
Quoted 2 lines

Yep, these are all intentionall fallthrough.

thanks
-- PMM

author
#10 lore raw

PATCH 3/9 accel/tcg/user-exec: silence the compiler warnings

In reply to Chen Qun

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
../accel/tcg/user-exec.c: In function ‘handle_cpu_signal’:
../accel/tcg/user-exec.c:169:13: warning: this statement may fall through [-Wimplicit-fallthrough=]

  169 |             cpu_exit_tb_from_sighandler(cpu, old_set);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../accel/tcg/user-exec.c:172:9: note: here
172 | default:

This exception branch fall through the 'default' branch and run the 'g_assert_not_reached' statement. So we could use "fall through" instead of "NORETURN" here.

---
Cc: Riku Voipio <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Paolo Bonzini <[email protected]>

---
 accel/tcg/user-exec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
accel/tcg/user-exec.c +1 -1
index 4ebe25461a..330468e990 100644
@@ -167,7 +167,7 @@ static inline int handle_cpu_signal(uintptr_t pc, siginfo_t *info,
              */
             clear_helper_retaddr();
             cpu_exit_tb_from_sighandler(cpu, old_set);
-            /* NORETURN */
+            /* fall through */
 
         default:
             g_assert_not_reached();
Signature · 1 line
2.27.0
#11 lore raw

Re: [PATCH 3/9] accel/tcg/user-exec: silence the compiler warnings

Quoted 26 lines · Chen Qun

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
../accel/tcg/user-exec.c: In function ‘handle_cpu_signal’:
../accel/tcg/user-exec.c:169:13: warning: this statement may fall through [-Wimplicit-fallthrough=]

  169 |             cpu_exit_tb_from_sighandler(cpu, old_set);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../accel/tcg/user-exec.c:172:9: note: here
172 | default:

This exception branch fall through the 'default' branch and run the 'g_assert_not_reached' statement. So we could use "fall through" instead of "NORETURN" here.

---
Cc: Riku Voipio <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Paolo Bonzini <[email protected]>

---
 accel/tcg/user-exec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
accel/tcg/user-exec.c +0 -0
index 4ebe25461a..330468e990 100644

accel/tcg/user-exec.c static inline int handle_cpu_signal(uintptr_t pc, siginfo_t *info, · line 170

Quoted 5 lines
accel/tcg/user-exec.c +1 -1
@@ -167,7 +167,7 @@ static inline int handle_cpu_signal(uintptr_t pc, siginfo_t *info,
              */
             clear_helper_retaddr();
             cpu_exit_tb_from_sighandler(cpu, old_set);
-            /* NORETURN */
+            /* fall through */

There should not be a fall through here since the previous function should never return. Does the warning go away if you mark the cpu_exit_tb_from_sighandler() function with QEMU_NORETURN ? If so, I think that would be the better fix.

Thomas

#12 lore raw

Re: [PATCH 3/9] accel/tcg/user-exec: silence the compiler warnings

Quoted 22 lines · Thomas Huth
Quoted 21 lines · Chen Qun

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
../accel/tcg/user-exec.c: In function ‘handle_cpu_signal’:
../accel/tcg/user-exec.c:169:13: warning: this statement may fall through [-Wimplicit-fallthrough=]

  169 |             cpu_exit_tb_from_sighandler(cpu, old_set);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../accel/tcg/user-exec.c:172:9: note: here
172 | default:

This exception branch fall through the 'default' branch and run the 'g_assert_not_reached' statement. So we could use "fall through" instead of "NORETURN" here.

---
Cc: Riku Voipio <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Paolo Bonzini <[email protected]>

---
 accel/tcg/user-exec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines

accel/tcg/user-exec.c static inline int handle_cpu_signal(uintptr_t pc, siginfo_t *info, · line 170

Quoted 10 lines
accel/tcg/user-exec.c +1 -1
index 4ebe25461a..330468e990 100644
@@ -167,7 +167,7 @@ static inline int handle_cpu_signal(uintptr_t pc, siginfo_t *info,
              */
             clear_helper_retaddr();
             cpu_exit_tb_from_sighandler(cpu, old_set);
-            /* NORETURN */
+            /* fall through */

There should not be a fall through here since the previous function should never return. Does the warning go away if you mark the cpu_exit_tb_from_sighandler() function with QEMU_NORETURN ? If so, I think that would be the better fix.

The compiler should have figured that out itself, due to cpu_loop_exit_noexc being marked QEMU_NORETURN. However,
if adding a second QEMU_NORETURN works, I'm fine with that.

As a very last resort, we can change the comment to

    /* no return, but fall through to assert not reached */

which correctly documents both the function preceding and also contains the regexp that the compiler is using for the warning.

r~

#13 lore raw

RE: [PATCH 3/9] accel/tcg/user-exec: silence the compiler warnings

Quoted 49 lines

-----Original Message-----
From: Richard Henderson [mailto:[email protected]]
Sent: Wednesday, October 28, 2020 11:38 PM
To: Thomas Huth <[email protected]>; Chenqun (kuhn) <[email protected]>; [email protected]; [email protected]
Cc: Zhanghailiang <[email protected]>; Riku Voipio <[email protected]>; Paolo Bonzini <[email protected]>; ganqixin <[email protected]>; Euler Robot <[email protected]>
Subject: Re: [PATCH 3/9] accel/tcg/user-exec: silence the compiler warnings

Quoted 2 lines · Thomas Huth
Quoted 1 line · Chen Qun

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed

warning:

Quoted 2 lines
Quoted 2 lines

../accel/tcg/user-exec.c: In function ‘handle_cpu_signal’:
../accel/tcg/user-exec.c:169:13: warning: this statement may fall through

[-Wimplicit-fallthrough=]

Quoted 6 lines
Quoted 6 lines
  169 |             cpu_exit_tb_from_sighandler(cpu, old_set);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../accel/tcg/user-exec.c:172:9: note: here
172 | default:

This exception branch fall through the 'default' branch and run the

'g_assert_not_reached' statement.

Quoted 12 lines
Quoted 12 lines

So we could use "fall through" instead of "NORETURN" here.

---
Cc: Riku Voipio <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Paolo Bonzini <[email protected]>

---
 accel/tcg/user-exec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 5 lines

accel/tcg/user-exec.c static inline int handle_cpu_signal(uintptr_t pc,

Quoted 5 lines
accel/tcg/user-exec.c index renamed from accel/tcg/user-exec.c +0 -0

4ebe25461a..330468e990 100644

accel/tcg/user-exec.c +0 -0
@@ -167,7 +167,7 @@ static inline int handle_cpu_signal(uintptr_t pc,

siginfo_t *info,

Quoted 6 lines
Quoted 5 lines
accel/tcg/user-exec.c +1 -1
              */
             clear_helper_retaddr();
             cpu_exit_tb_from_sighandler(cpu, old_set);
-            /* NORETURN */
+            /* fall through */
Quoted 9 lines
Quoted 4 lines

There should not be a fall through here since the previous function should never return. Does the warning go away if you mark the cpu_exit_tb_from_sighandler() function with QEMU_NORETURN ? If so, I think that would be the better fix.

The compiler should have figured that out itself, due to cpu_loop_exit_noexc being marked QEMU_NORETURN. However, if adding a second QEMU_NORETURN works, I'm fine with that.

I tried to add QEMU_NORETURN to the cpu_exit_tb_from_sighandler() function.
And then the compiler warning was cleared. It seems to be a better fix.

Thanks,
Chen Qun

Quoted 7 lines

As a very last resort, we can change the comment to

    /* no return, but fall through to assert not reached */

which correctly documents both the function preceding and also contains the regexp that the compiler is using for the warning.

author
#14 lore raw

PATCH 4/9 linux-user/mips/cpu_loop: silence the compiler warnings

In reply to Chen Qun

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
linux-user/mips/cpu_loop.c: In function ‘cpu_loop’:
linux-user/mips/cpu_loop.c:104:24: warning: this statement may fall through [-Wimplicit-fallthrough=]
104 | if ((ret = get_user_ual(arg8, sp_reg + 28)) != 0) {
| ^
linux-user/mips/cpu_loop.c:107:17: note: here

  107 |                 case 7:
      |                 ^~~~

linux-user/mips/cpu_loop.c:108:24: warning: this statement may fall through [-Wimplicit-fallthrough=]
108 | if ((ret = get_user_ual(arg7, sp_reg + 24)) != 0) {
| ^
linux-user/mips/cpu_loop.c:111:17: note: here

  111 |                 case 6:
      |                 ^~~~

linux-user/mips/cpu_loop.c:112:24: warning: this statement may fall through [-Wimplicit-fallthrough=]
112 | if ((ret = get_user_ual(arg6, sp_reg + 20)) != 0) {
| ^
linux-user/mips/cpu_loop.c:115:17: note: here

  115 |                 case 5:
      |                 ^~~~

Add the corresponding "fall through" comment to fix it.

---
Cc: Laurent Vivier <[email protected]>

---
 linux-user/mips/cpu_loop.c | 4 ++++
 1 file changed, 4 insertions(+)
linux-user/mips/cpu_loop.c +4 -0
index 553e8ca7f5..cfe7ba5c47 100644
@@ -104,18 +104,22 @@ void cpu_loop(CPUMIPSState *env)
                     if ((ret = get_user_ual(arg8, sp_reg + 28)) != 0) {
                         goto done_syscall;
                     }
+                    /* fall through */
                 case 7:
                     if ((ret = get_user_ual(arg7, sp_reg + 24)) != 0) {
                         goto done_syscall;
                     }
+                    /* fall through */
                 case 6:
                     if ((ret = get_user_ual(arg6, sp_reg + 20)) != 0) {
                         goto done_syscall;
                     }
+                    /* fall through */
                 case 5:
                     if ((ret = get_user_ual(arg5, sp_reg + 16)) != 0) {
                         goto done_syscall;
                     }
+                    /* fall through */
                 default:
                     break;
                 }
Signature · 1 line
2.27.0
Reviewed-by on v1 4/9
#15 lore raw

Re: [PATCH 4/9] linux-user/mips/cpu_loop: silence the compiler warnings

Quoted 48 lines · Chen Qun

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
linux-user/mips/cpu_loop.c: In function ‘cpu_loop’:
linux-user/mips/cpu_loop.c:104:24: warning: this statement may fall through [-Wimplicit-fallthrough=]
104 | if ((ret = get_user_ual(arg8, sp_reg + 28)) != 0) {
| ^
linux-user/mips/cpu_loop.c:107:17: note: here

  107 |                 case 7:
      |                 ^~~~

linux-user/mips/cpu_loop.c:108:24: warning: this statement may fall through [-Wimplicit-fallthrough=]
108 | if ((ret = get_user_ual(arg7, sp_reg + 24)) != 0) {
| ^
linux-user/mips/cpu_loop.c:111:17: note: here

  111 |                 case 6:
      |                 ^~~~

linux-user/mips/cpu_loop.c:112:24: warning: this statement may fall through [-Wimplicit-fallthrough=]
112 | if ((ret = get_user_ual(arg6, sp_reg + 20)) != 0) {
| ^
linux-user/mips/cpu_loop.c:115:17: note: here

  115 |                 case 5:
      |                 ^~~~

Add the corresponding "fall through" comment to fix it.

---
Cc: Laurent Vivier <[email protected]>

---
 linux-user/mips/cpu_loop.c | 4 ++++
 1 file changed, 4 insertions(+)
linux-user/mips/cpu_loop.c +2 -0
index 553e8ca7f5..cfe7ba5c47 100644
@@ -104,18 +104,22 @@ void cpu_loop(CPUMIPSState *env)
                     if ((ret = get_user_ual(arg8, sp_reg + 28)) != 0) {
                         goto done_syscall;
                     }
+                    /* fall through */
                 case 7:
                     if ((ret = get_user_ual(arg7, sp_reg + 24)) != 0) {
                         goto done_syscall;
                     }
+                    /* fall through */
                 case 6:
                     if ((ret = get_user_ual(arg6, sp_reg + 20)) != 0) {
                         goto done_syscall;

linux-user/mips/cpu_loop.c void cpu_loop(CPUMIPSState *env) · line 125

Quoted 10 lines
linux-user/mips/cpu_loop.c +2 -0
                     }
+                    /* fall through */
                 case 5:
                     if ((ret = get_user_ual(arg5, sp_reg + 16)) != 0) {
                         goto done_syscall;
                     }
+                    /* fall through */
                 default:
                     break;
                 }
author
#16 lore raw

PATCH 5/9 target/sparc/translate: silence the compiler warnings

In reply to Chen Qun

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
target/sparc/translate.c: In function ‘gen_st_asi’:
target/sparc/translate.c:2320:12: warning: this statement may fall through [-Wimplicit-fallthrough=]
2320 | if (!(dc->def->features & CPU_FEATURE_HYPV)) {
| ^
target/sparc/translate.c:2329:5: note: here

 2329 |     case GET_ASI_DIRECT:
      |     ^~~~

The "fall through" statement place is not correctly identified by the compiler.

---
Cc: Mark Cave-Ayland <[email protected]>
Cc: Artyom Tarasenko <[email protected]>

---
 target/sparc/translate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/sparc/translate.c +1 -1
index 1a4efd4ed6..a3d9aaa46b 100644
@@ -2324,8 +2324,8 @@ static void gen_st_asi(DisasContext *dc, TCGv src, TCGv addr,
         }
         /* in OpenSPARC T1+ CPUs TWINX ASIs in store instructions
          * are ST_BLKINIT_ ASIs */
-        /* fall through */
 #endif
+        /* fall through */
     case GET_ASI_DIRECT:
         gen_address_mask(dc, addr);
         tcg_gen_qemu_st_tl(src, addr, da.mem_idx, da.memop);
Signature · 1 line
2.27.0
Reviewed-by on v1 5/9
#17 lore raw

Re: [PATCH 5/9] target/sparc/translate: silence the compiler warnings

ср, 28 окт. 2020 г., 5:19 Chen Qun <[email protected]>:

Quoted 8 lines

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
target/sparc/translate.c: In function ‘gen_st_asi’:
target/sparc/translate.c:2320:12: warning: this statement may fall through [-Wimplicit-fallthrough=]
2320 | if (!(dc->def->features & CPU_FEATURE_HYPV)) {
| ^
target/sparc/translate.c:2329:5: note: here

Quoted 9 lines
 2329 |     case GET_ASI_DIRECT:
      |     ^~~~

The "fall through" statement place is not correctly identified by the compiler.

---

Quoted 25 lines
Cc Mark Cave-Ayland <[email protected]>
Cc Artyom Tarasenko <[email protected]>
---
 target/sparc/translate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/sparc/translate.c +1 -1
index 1a4efd4ed6..a3d9aaa46b 100644
@@ -2324,8 +2324,8 @@ static void gen_st_asi(DisasContext *dc, TCGv src,
 TCGv addr,
         }
         /* in OpenSPARC T1+ CPUs TWINX ASIs in store instructions
          * are ST_BLKINIT_ ASIs */
-        /* fall through */
 #endif
+        /* fall through */
     case GET_ASI_DIRECT:
         gen_address_mask(dc, addr);
         tcg_gen_qemu_st_tl(src, addr, da.mem_idx, da.memop);

--
2.27.0

Reviewed-by on v1 5/9
#18 lore raw

Re: [PATCH 5/9] target/sparc/translate: silence the compiler warnings

In reply to Chen Qun
Quoted 26 lines · Chen Qun

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
target/sparc/translate.c: In function ‘gen_st_asi’:
target/sparc/translate.c:2320:12: warning: this statement may fall through [-Wimplicit-fallthrough=]
2320 | if (!(dc->def->features & CPU_FEATURE_HYPV)) {
| ^
target/sparc/translate.c:2329:5: note: here

 2329 |     case GET_ASI_DIRECT:
      |     ^~~~

The "fall through" statement place is not correctly identified by the compiler.

---
Cc: Mark Cave-Ayland <[email protected]>
Cc: Artyom Tarasenko <[email protected]>

---
 target/sparc/translate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/sparc/translate.c +0 -0
index 1a4efd4ed6..a3d9aaa46b 100644

target/sparc/translate.c static void gen_st_asi(DisasContext *dc, TCGv src, TCGv addr, · line 2331

Quoted 9 lines
target/sparc/translate.c +1 -1
@@ -2324,8 +2324,8 @@ static void gen_st_asi(DisasContext *dc, TCGv src, TCGv addr,
         }
         /* in OpenSPARC T1+ CPUs TWINX ASIs in store instructions
          * are ST_BLKINIT_ ASIs */
-        /* fall through */
 #endif
+        /* fall through */
     case GET_ASI_DIRECT:
         gen_address_mask(dc, addr);
         tcg_gen_qemu_st_tl(src, addr, da.mem_idx, da.memop);
author
#19 lore raw

PATCH 6/9 target/sparc/win_helper: silence the compiler warnings

In reply to Chen Qun

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
target/sparc/win_helper.c: In function ‘get_gregset’:
target/sparc/win_helper.c:304:9: warning: this statement may fall through [-Wimplicit-fallthrough=]

  304 |         trace_win_helper_gregset_error(pstate);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
target/sparc/win_helper.c:306:5: note: here
  306 |     case 0:
      |     ^~~~

Add the corresponding "fall through" comment to fix it.

---
Cc: Mark Cave-Ayland <[email protected]>
Cc: Artyom Tarasenko <[email protected]>

---
 target/sparc/win_helper.c | 1 +
 1 file changed, 1 insertion(+)
target/sparc/win_helper.c +1 -0
index 8290a21142..32eacc05e6 100644
@@ -303,6 +303,7 @@ static inline uint64_t *get_gregset(CPUSPARCState *env, uint32_t pstate)
     default:
         trace_win_helper_gregset_error(pstate);
         /* pass through to normal set of global registers */
+        /* fall through */
     case 0:
         return env->bgregs;
     case PS_AG:
Signature · 1 line
2.27.0
Reviewed-by on v1 6/9
#20 lore raw

Re: [PATCH 6/9] target/sparc/win_helper: silence the compiler warnings

ср, 28 окт. 2020 г., 5:19 Chen Qun <[email protected]>:

Quoted 11 lines

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
target/sparc/win_helper.c: In function ‘get_gregset’:
target/sparc/win_helper.c:304:9: warning: this statement may fall through [-Wimplicit-fallthrough=]

  304 |         trace_win_helper_gregset_error(pstate);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
target/sparc/win_helper.c:306:5: note: here
  306 |     case 0:
      |     ^~~~
Quoted 5 lines

Add the corresponding "fall through" comment to fix it.

---

Quoted 23 lines
Cc Mark Cave-Ayland <[email protected]>
Cc Artyom Tarasenko <[email protected]>
---
 target/sparc/win_helper.c | 1 +
 1 file changed, 1 insertion(+)
target/sparc/win_helper.c +1 -0
index 8290a21142..32eacc05e6 100644
@@ -303,6 +303,7 @@ static inline uint64_t *get_gregset(CPUSPARCState
 *env, uint32_t pstate)
     default:
         trace_win_helper_gregset_error(pstate);
         /* pass through to normal set of global registers */
+        /* fall through */
     case 0:
         return env->bgregs;

case PS_AG:
--
2.27.0

#21 lore raw

Re: [PATCH 6/9] target/sparc/win_helper: silence the compiler warnings

In reply to Chen Qun
Quoted 25 lines · Chen Qun

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
target/sparc/win_helper.c: In function ‘get_gregset’:
target/sparc/win_helper.c:304:9: warning: this statement may fall through [-Wimplicit-fallthrough=]

  304 |         trace_win_helper_gregset_error(pstate);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
target/sparc/win_helper.c:306:5: note: here
  306 |     case 0:
      |     ^~~~

Add the corresponding "fall through" comment to fix it.

---
Cc: Mark Cave-Ayland <[email protected]>
Cc: Artyom Tarasenko <[email protected]>

---
 target/sparc/win_helper.c | 1 +
 1 file changed, 1 insertion(+)
target/sparc/win_helper.c +0 -0
index 8290a21142..32eacc05e6 100644

target/sparc/win_helper.c static inline uint64_t *get_gregset(CPUSPARCState *env, uint32_t pstate) · line 306

Quoted 4 lines
target/sparc/win_helper.c +1 -0
@@ -303,6 +303,7 @@ static inline uint64_t *get_gregset(CPUSPARCState *env, uint32_t pstate)
     default:
         trace_win_helper_gregset_error(pstate);
         /* pass through to normal set of global registers */
+        /* fall through */

Can you keep the comment, doing s/pass/fall/?

Quoted 4 lines
target/sparc/win_helper.c +0 -0
     case 0:
         return env->bgregs;
     case PS_AG:
#22 lore raw

RE: [PATCH 6/9] target/sparc/win_helper: silence the compiler warnings

Quoted 42 lines

-----Original Message-----
From: Philippe Mathieu-Daudé [mailto:[email protected]] On Behalf Of Philippe Mathieu-Daudé
Sent: Wednesday, October 28, 2020 5:51 PM
To: Chenqun (kuhn) <[email protected]>; [email protected]; [email protected]
Cc: Zhanghailiang <[email protected]>; Mark Cave-Ayland <[email protected]>; ganqixin <[email protected]>; Euler Robot <[email protected]>; Artyom Tarasenko <[email protected]>
Subject: Re: [PATCH 6/9] target/sparc/win_helper: silence the compiler warnings

Quoted 1 line · Chen Qun

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed

warning:

Quoted 2 lines

target/sparc/win_helper.c: In function ‘get_gregset’:
target/sparc/win_helper.c:304:9: warning: this statement may fall through

[-Wimplicit-fallthrough=]

target/sparc/win_helper.c static inline uint64_t *get_gregset(CPUSPARCState

Quoted 22 lines
  304 |         trace_win_helper_gregset_error(pstate);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
target/sparc/win_helper.c:306:5: note: here
  306 |     case 0:
      |     ^~~~

Add the corresponding "fall through" comment to fix it.

---
Cc: Mark Cave-Ayland <[email protected]>
Cc: Artyom Tarasenko <[email protected]>

---
 target/sparc/win_helper.c | 1 +
 1 file changed, 1 insertion(+)
target/sparc/win_helper.c +0 -0
index 8290a21142..32eacc05e6 100644
@@ -303,6 +303,7 @@ static inline uint64_t *get_gregset(CPUSPARCState

*env, uint32_t pstate)

Quoted 7 lines

target/sparc/win_helper.c static inline uint64_t *get_gregset(CPUSPARCState *env, uint32_t pstate) · line 306

Quoted 4 lines
target/sparc/win_helper.c +1 -0
     default:
         trace_win_helper_gregset_error(pstate);
         /* pass through to normal set of global registers */
+        /* fall through */

Can you keep the comment, doing s/pass/fall/?

That looks good, too.

Thanks,
Chen Qun

Quoted 4 lines
Quoted 4 lines
target/sparc/win_helper.c +0 -0
     case 0:
         return env->bgregs;
     case PS_AG:
author
#23 lore raw

PATCH 7/9 ppc: silence the compiler warnings

In reply to Chen Qun

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
hw/ppc/ppc.c: In function ‘ppc6xx_set_irq’:
hw/ppc/ppc.c:118:16: warning: this statement may fall through [-Wimplicit-fallthrough=]
118 | if (level) {
| ^
hw/ppc/ppc.c:123:9: note: here

  123 |         case PPC6xx_INPUT_INT:
      |         ^~~~

Add the corresponding "fall through" comment to fix it.

---
Cc: David Gibson <[email protected]>

---
 hw/ppc/ppc.c | 1 +
 1 file changed, 1 insertion(+)
hw/ppc/ppc.c +1 -0
index 4a11fb1640..f9eb8f21b4 100644
@@ -120,6 +120,7 @@ static void ppc6xx_set_irq(void *opaque, int pin, int level)
             } else {
                 cpu_ppc_tb_stop(env);
             }
+            /* fall through */
         case PPC6xx_INPUT_INT:
             /* Level sensitive - active high */
             LOG_IRQ("%s: set the external IRQ state to %d\n",
Signature · 1 line
2.27.0
Acked-by on v1 7/9
#24 lore raw

Re: [PATCH 7/9] ppc: silence the compiler warnings

Quoted 6 lines · Chen Qun

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
hw/ppc/ppc.c: In function ‘ppc6xx_set_irq’:
hw/ppc/ppc.c:118:16: warning: this statement may fall through [-Wimplicit-fallthrough=]
118 | if (level) {
| ^
hw/ppc/ppc.c:123:9: note: here

Quoted 7 lines
  123 |         case PPC6xx_INPUT_INT:
      |         ^~~~

Add the corresponding "fall through" comment to fix it.

Quoted 18 lines

---
Cc: David Gibson <[email protected]>

---
 hw/ppc/ppc.c | 1 +
 1 file changed, 1 insertion(+)
hw/ppc/ppc.c +1 -0
index 4a11fb1640..f9eb8f21b4 100644
@@ -120,6 +120,7 @@ static void ppc6xx_set_irq(void *opaque, int pin, int level)
             } else {
                 cpu_ppc_tb_stop(env);
             }
+            /* fall through */
         case PPC6xx_INPUT_INT:
             /* Level sensitive - active high */
             LOG_IRQ("%s: set the external IRQ state to %d\n",
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#25 lore raw

Re: [PATCH 7/9] ppc: silence the compiler warnings

Quoted 23 lines · David Gibson
Quoted 6 lines · Chen Qun

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
hw/ppc/ppc.c: In function ‘ppc6xx_set_irq’:
hw/ppc/ppc.c:118:16: warning: this statement may fall through [-Wimplicit-fallthrough=]
118 | if (level) {
| ^
hw/ppc/ppc.c:123:9: note: here

Quoted 7 lines
  123 |         case PPC6xx_INPUT_INT:
      |         ^~~~

Add the corresponding "fall through" comment to fix it.

Quoted 6 lines

---
Cc: David Gibson <[email protected]>

---
 hw/ppc/ppc.c | 1 +
 1 file changed, 1 insertion(+)
Quoted 13 lines

hw/ppc/ppc.c static void ppc6xx_set_irq(void *opaque, int pin, int level) · line 126

Quoted 12 lines
hw/ppc/ppc.c +1 -0
index 4a11fb1640..f9eb8f21b4 100644
@@ -120,6 +120,7 @@ static void ppc6xx_set_irq(void *opaque, int pin, int level)
             } else {
                 cpu_ppc_tb_stop(env);
             }
+            /* fall through */
         case PPC6xx_INPUT_INT:
             /* Level sensitive - active high */
             LOG_IRQ("%s: set the external IRQ state to %d\n",

Is that fall through actually really the right thing to do here? I'd rather expect to see a PPC_INTERRUPT_DECR instead of a PPC_INTERRUPT_EXT in case someone messes with the TBEN pin? So I assume this is likely rather bug and we should a "break" statement here instead?

Thomas

#26 lore raw

Re: [PATCH 7/9] ppc: silence the compiler warnings

Quoted 38 lines · Thomas Huth
Quoted 23 lines · David Gibson
Quoted 6 lines · Chen Qun

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
hw/ppc/ppc.c: In function ‘ppc6xx_set_irq’:
hw/ppc/ppc.c:118:16: warning: this statement may fall through [-Wimplicit-fallthrough=]
118 | if (level) {
| ^
hw/ppc/ppc.c:123:9: note: here

Quoted 7 lines
  123 |         case PPC6xx_INPUT_INT:
      |         ^~~~

Add the corresponding "fall through" comment to fix it.

Quoted 6 lines

---
Cc: David Gibson <[email protected]>

---
 hw/ppc/ppc.c | 1 +
 1 file changed, 1 insertion(+)
Quoted 13 lines

hw/ppc/ppc.c static void ppc6xx_set_irq(void *opaque, int pin, int level) · line 126

Quoted 12 lines
hw/ppc/ppc.c +1 -0
index 4a11fb1640..f9eb8f21b4 100644
@@ -120,6 +120,7 @@ static void ppc6xx_set_irq(void *opaque, int pin, int level)
             } else {
                 cpu_ppc_tb_stop(env);
             }
+            /* fall through */
         case PPC6xx_INPUT_INT:
             /* Level sensitive - active high */
             LOG_IRQ("%s: set the external IRQ state to %d\n",
Quoted 4 lines

Is that fall through actually really the right thing to do here? I'd rather expect to see a PPC_INTERRUPT_DECR instead of a PPC_INTERRUPT_EXT in case someone messes with the TBEN pin? So I assume this is likely rather bug and we should a "break" statement here instead?

Oh.. good catch, I think I misread this. I thought the change was correct, because DECRs look somewhat like external interrupts. But this is TBEN, not a DECR interrupt per se. So, yes, I think this was a bug and it should be a break instead.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#27 lore raw

RE: [PATCH 7/9] ppc: silence the compiler warnings

Quoted 56 lines

-----Original Message-----
From: David Gibson [mailto:[email protected]]
Sent: Thursday, October 29, 2020 7:39 AM
To: Thomas Huth <[email protected]>
Cc: Chenqun (kuhn) <[email protected]>; [email protected]; Euler Robot <[email protected]>; [email protected]; ganqixin <[email protected]>; Zhanghailiang <[email protected]>; [email protected]
Subject: Re: [PATCH 7/9] ppc: silence the compiler warnings

Quoted 3 lines · Thomas Huth
Quoted 2 lines · David Gibson
Quoted 1 line · Chen Qun

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed

warning:

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

hw/ppc/ppc.c: In function ‘ppc6xx_set_irq’:
hw/ppc/ppc.c:118:16: warning: this statement may fall through

[-Wimplicit-fallthrough=]

Quoted 19 lines
Quoted 19 lines
Quoted 10 lines

118 | if (level) {
| ^
hw/ppc/ppc.c:123:9: note: here

  123 |         case PPC6xx_INPUT_INT:
      |         ^~~~

Add the corresponding "fall through" comment to fix it.

Quoted 6 lines

---
Cc: David Gibson <[email protected]>

---
 hw/ppc/ppc.c | 1 +
 1 file changed, 1 insertion(+)
Quoted 5 lines
Quoted 5 lines

hw/ppc/ppc.c static void ppc6xx_set_irq(void *opaque, int pin,

Quoted 5 lines
hw/ppc/ppc.c index renamed from hw/ppc/ppc.c +0 -0

4a11fb1640..f9eb8f21b4 100644

hw/ppc/ppc.c +0 -0
@@ -120,6 +120,7 @@ static void ppc6xx_set_irq(void *opaque, int pin,

int level)

Quoted 9 lines
Quoted 8 lines

hw/ppc/ppc.c static void ppc6xx_set_irq(void *opaque, int pin, int level) · line 126

Quoted 7 lines
hw/ppc/ppc.c +1 -0
             } else {
                 cpu_ppc_tb_stop(env);
             }
+            /* fall through */
         case PPC6xx_INPUT_INT:
             /* Level sensitive - active high */
             LOG_IRQ("%s: set the external IRQ state to %d\n",
Quoted 4 lines

Is that fall through actually really the right thing to do here? I'd rather expect to see a PPC_INTERRUPT_DECR instead of a PPC_INTERRUPT_EXT in case someone messes with the TBEN pin? So I assume this is likely rather bug and we should a "break" statement here

Quoted 7 lines

instead?

Oh.. good catch, I think I misread this. I thought the change was correct, because DECRs look somewhat like external interrupts. But this is TBEN, not a DECR interrupt per se. So, yes, I think this was a bug and it should be a break instead.

This bug looks like it's been hidden for years. Thanks for your point. According to your opinion, I will modify it in the next version.

Thanks,
Chen Qun

Quoted 6 lines

--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_
_other_

				| _way_ _around_!

http://www.ozlabs.org/~dgibson

author
#28 lore raw

PATCH 8/9 target/ppc: silence the compiler warnings

In reply to Chen Qun

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
target/ppc/mmu_helper.c: In function ‘dump_mmu’:
target/ppc/mmu_helper.c:1351:12: warning: this statement may fall through [-Wimplicit-fallthrough=]
1351 | if (ppc64_v3_radix(env_archcpu(env))) {
| ^
target/ppc/mmu_helper.c:1358:5: note: here

 1358 |     default:
      |     ^~~~~~~

Add the corresponding "fall through" comment to fix it.

---
Cc: David Gibson <[email protected]>

---
 target/ppc/mmu_helper.c | 1 +
 1 file changed, 1 insertion(+)
target/ppc/mmu_helper.c +1 -0
index 8972714775..51749b62df 100644
@@ -1355,6 +1355,7 @@ void dump_mmu(CPUPPCState *env)
             break;
         }
 #endif
+        /* fall through */
     default:
         qemu_log_mask(LOG_UNIMP, "%s: unimplemented\n", __func__);
     }
Signature · 1 line
2.27.0
Acked-by on v1 8/9
#29 lore raw

Re: [PATCH 8/9] target/ppc: silence the compiler warnings

Quoted 6 lines · Chen Qun

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
target/ppc/mmu_helper.c: In function ‘dump_mmu’:
target/ppc/mmu_helper.c:1351:12: warning: this statement may fall through [-Wimplicit-fallthrough=]
1351 | if (ppc64_v3_radix(env_archcpu(env))) {
| ^
target/ppc/mmu_helper.c:1358:5: note: here

Quoted 7 lines
 1358 |     default:
      |     ^~~~~~~

Add the corresponding "fall through" comment to fix it.

Quoted 18 lines

---
Cc: David Gibson <[email protected]>

---
 target/ppc/mmu_helper.c | 1 +
 1 file changed, 1 insertion(+)
target/ppc/mmu_helper.c +1 -0
index 8972714775..51749b62df 100644
@@ -1355,6 +1355,7 @@ void dump_mmu(CPUPPCState *env)
             break;
         }
 #endif
+        /* fall through */
     default:
         qemu_log_mask(LOG_UNIMP, "%s: unimplemented\n", __func__);
     }
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#30 lore raw

Re: [PATCH 8/9] target/ppc: silence the compiler warnings

In reply to Chen Qun
Quoted 24 lines · Chen Qun

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
target/ppc/mmu_helper.c: In function ‘dump_mmu’:
target/ppc/mmu_helper.c:1351:12: warning: this statement may fall through [-Wimplicit-fallthrough=]
1351 | if (ppc64_v3_radix(env_archcpu(env))) {
| ^
target/ppc/mmu_helper.c:1358:5: note: here

 1358 |     default:
      |     ^~~~~~~

Add the corresponding "fall through" comment to fix it.

---
Cc: David Gibson <[email protected]>

---
 target/ppc/mmu_helper.c | 1 +
 1 file changed, 1 insertion(+)
target/ppc/mmu_helper.c +0 -0
index 8972714775..51749b62df 100644

target/ppc/mmu_helper.c void dump_mmu(CPUPPCState *env) · line 1358

Quoted 4 lines
target/ppc/mmu_helper.c +1 -0
@@ -1355,6 +1355,7 @@ void dump_mmu(CPUPPCState *env)
             break;
         }
 #endif
+        /* fall through */

I'm surprise the compiler emit a warning for missing comment, but don't emit one for superfluous and confusing ones (when building a ppc32-only target). You'd need to put this before the #endif.

But instead of this band-aid to silent warning, replace the TODO by a LOG_UNIMP call, and add a break before the #endif.

Quoted 4 lines
target/ppc/mmu_helper.c +0 -0
     default:
         qemu_log_mask(LOG_UNIMP, "%s: unimplemented\n", __func__);
     }
#31 lore raw

Re: [PATCH 8/9] target/ppc: silence the compiler warnings

Quoted 35 lines · Philippe Mathieu-Daudé
Quoted 24 lines · Chen Qun

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
target/ppc/mmu_helper.c: In function ‘dump_mmu’:
target/ppc/mmu_helper.c:1351:12: warning: this statement may fall through [-Wimplicit-fallthrough=]
1351 | if (ppc64_v3_radix(env_archcpu(env))) {
| ^
target/ppc/mmu_helper.c:1358:5: note: here

 1358 |     default:
      |     ^~~~~~~

Add the corresponding "fall through" comment to fix it.

---
Cc: David Gibson <[email protected]>

---
 target/ppc/mmu_helper.c | 1 +
 1 file changed, 1 insertion(+)
target/ppc/mmu_helper.c +0 -0
index 8972714775..51749b62df 100644

target/ppc/mmu_helper.c void dump_mmu(CPUPPCState *env) · line 1358

Quoted 4 lines
target/ppc/mmu_helper.c +1 -0
@@ -1355,6 +1355,7 @@ void dump_mmu(CPUPPCState *env)
             break;
         }
 #endif
+        /* fall through */

I'm surprise the compiler emit a warning for missing comment, but don't emit one for superfluous and confusing ones (when building a ppc32-only target). You'd need to put this before the #endif.

Quoted 2 lines

But instead of this band-aid to silent warning, replace the TODO by a LOG_UNIMP call, and add a break before the #endif.

+1 for replacing the TODO with a LOG_UNIMP call and adding a break instead, that would look way less messy than the current code.

Thanks,
Thomas

#32 lore raw

Re: [PATCH 8/9] target/ppc: silence the compiler warnings

Quoted 36 lines · Thomas Huth
Quoted 35 lines · Philippe Mathieu-Daudé
Quoted 24 lines · Chen Qun

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
target/ppc/mmu_helper.c: In function ‘dump_mmu’:
target/ppc/mmu_helper.c:1351:12: warning: this statement may fall through [-Wimplicit-fallthrough=]
1351 | if (ppc64_v3_radix(env_archcpu(env))) {
| ^
target/ppc/mmu_helper.c:1358:5: note: here

 1358 |     default:
      |     ^~~~~~~

Add the corresponding "fall through" comment to fix it.

---
Cc: David Gibson <[email protected]>

---
 target/ppc/mmu_helper.c | 1 +
 1 file changed, 1 insertion(+)
target/ppc/mmu_helper.c +0 -0
index 8972714775..51749b62df 100644

target/ppc/mmu_helper.c void dump_mmu(CPUPPCState *env) · line 1358

Quoted 4 lines
target/ppc/mmu_helper.c +1 -0
@@ -1355,6 +1355,7 @@ void dump_mmu(CPUPPCState *env)
             break;
         }
 #endif
+        /* fall through */

I'm surprise the compiler emit a warning for missing comment, but don't emit one for superfluous and confusing ones (when building a ppc32-only target). You'd need to put this before the #endif.

Quoted 5 lines
Quoted 2 lines

But instead of this band-aid to silent warning, replace the TODO by a LOG_UNIMP call, and add a break before the #endif.

+1 for replacing the TODO with a LOG_UNIMP call and adding a break instead, that would look way less messy than the current code.

True, that would be a better approach.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#33 lore raw

RE: [PATCH 8/9] target/ppc: silence the compiler warnings

Quoted 49 lines

-----Original Message-----
From: David Gibson [mailto:[email protected]]
Sent: Thursday, October 29, 2020 7:39 AM
To: Thomas Huth <[email protected]>
Cc: Philippe Mathieu-Daudé <[email protected]>; Chenqun (kuhn) <[email protected]>; [email protected]; [email protected]; Euler Robot <[email protected]>; Zhanghailiang <[email protected]>; ganqixin <[email protected]>
Subject: Re: [PATCH 8/9] target/ppc: silence the compiler warnings

Quoted 3 lines · Thomas Huth
Quoted 2 lines · Philippe Mathieu-Daudé
Quoted 1 line · Chen Qun

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed

warning:

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

target/ppc/mmu_helper.c: In function ‘dump_mmu’:
target/ppc/mmu_helper.c:1351:12: warning: this statement may fall

through [-Wimplicit-fallthrough=]

Quoted 30 lines
Quoted 30 lines
Quoted 21 lines

1351 | if (ppc64_v3_radix(env_archcpu(env))) {
| ^
target/ppc/mmu_helper.c:1358:5: note: here

 1358 |     default:
      |     ^~~~~~~

Add the corresponding "fall through" comment to fix it.

---
Cc: David Gibson <[email protected]>

---
 target/ppc/mmu_helper.c | 1 +
 1 file changed, 1 insertion(+)
target/ppc/mmu_helper.c +0 -0
index 8972714775..51749b62df 100644

target/ppc/mmu_helper.c void dump_mmu(CPUPPCState *env) · line 1358

Quoted 4 lines
target/ppc/mmu_helper.c +1 -0
@@ -1355,6 +1355,7 @@ void dump_mmu(CPUPPCState *env)
             break;
         }
 #endif
+        /* fall through */

I'm surprise the compiler emit a warning for missing comment, but don't emit one for superfluous and confusing ones (when building a ppc32-only target). You'd need to put this before the #endif.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

But instead of this band-aid to silent warning, replace the TODO by a LOG_UNIMP call, and add a break before the #endif.

+1 for replacing the TODO with a LOG_UNIMP call and adding a break +instead,
that would look way less messy than the current code.

True, that would be a better approach.

Yeah, that's a good idea.
I'll modify it in the v2.

Thanks,
Chen Qun

Quoted 7 lines

--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_
_other_

				| _way_ _around_!

http://www.ozlabs.org/~dgibson

author
#34 lore raw

PATCH 9/9 hw/timer/renesas_tmr: silence the compiler warnings

In reply to Chen Qun

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
../hw/timer/renesas_tmr.c: In function ‘tmr_read’:
../hw/timer/renesas_tmr.c:221:19: warning: this statement may fall through [-Wimplicit-fallthrough=]
221 | } else if (ch == 0) {i
| ^
../hw/timer/renesas_tmr.c:224:5: note: here

  224 |     case A_TCORB:
      |     ^~~~

Add the corresponding "fall through" comment to fix it.

---
Cc: Yoshinori Sato <[email protected]>
Cc: Magnus Damm <[email protected]>

---
 hw/timer/renesas_tmr.c | 1 +
 1 file changed, 1 insertion(+)
hw/timer/renesas_tmr.c +1 -0
index 446f2eacdd..e03a8155b2 100644
@@ -221,6 +221,7 @@ static uint64_t tmr_read(void *opaque, hwaddr addr, unsigned size)
         } else if (ch == 0) {
             return concat_reg(tmr->tcora);
         }
+        /* fall through */
     case A_TCORB:
         if (size == 1) {
             return tmr->tcorb[ch];
Signature · 1 line
2.27.0
#35 lore raw

Re: [PATCH 9/9] hw/timer/renesas_tmr: silence the compiler warnings

Quoted 26 lines · Chen Qun

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
../hw/timer/renesas_tmr.c: In function ‘tmr_read’:
../hw/timer/renesas_tmr.c:221:19: warning: this statement may fall through [-Wimplicit-fallthrough=]
221 | } else if (ch == 0) {i
| ^
../hw/timer/renesas_tmr.c:224:5: note: here

  224 |     case A_TCORB:
      |     ^~~~

Add the corresponding "fall through" comment to fix it.

---
Cc: Yoshinori Sato <[email protected]>
Cc: Magnus Damm <[email protected]>

---
 hw/timer/renesas_tmr.c | 1 +
 1 file changed, 1 insertion(+)
hw/timer/renesas_tmr.c +0 -0
index 446f2eacdd..e03a8155b2 100644

hw/timer/renesas_tmr.c static uint64_t tmr_read(void *opaque, hwaddr addr, unsigned size) · line 227

Quoted 7 lines
hw/timer/renesas_tmr.c +1 -0
@@ -221,6 +221,7 @@ static uint64_t tmr_read(void *opaque, hwaddr addr, unsigned size)
         } else if (ch == 0) {
             return concat_reg(tmr->tcora);
         }
+        /* fall through */
     case A_TCORB:
         if (size == 1) {
             return tmr->tcorb[ch];

You fixed A_TCORA but not A_TCORB...

How the Euler Robot works? Like Coverity?

#36 lore raw

Re: [PATCH 9/9] hw/timer/renesas_tmr: silence the compiler warnings

Quoted 21 lines · Philippe Mathieu-Daudé
Quoted 20 lines · Chen Qun

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
../hw/timer/renesas_tmr.c: In function ‘tmr_read’:
../hw/timer/renesas_tmr.c:221:19: warning: this statement may fall through [-Wimplicit-fallthrough=]
221 | } else if (ch == 0) {i
| ^
../hw/timer/renesas_tmr.c:224:5: note: here

  224 |     case A_TCORB:
      |     ^~~~

Add the corresponding "fall through" comment to fix it.

---
Cc: Yoshinori Sato <[email protected]>
Cc: Magnus Damm <[email protected]>

---
 hw/timer/renesas_tmr.c | 1 +
 1 file changed, 1 insertion(+)
Quoted 15 lines

hw/timer/renesas_tmr.c static uint64_t tmr_read(void *opaque, hwaddr addr, unsigned size) · line 227

Quoted 13 lines
hw/timer/renesas_tmr.c +1 -0
index 446f2eacdd..e03a8155b2 100644
@@ -221,6 +221,7 @@ static uint64_t tmr_read(void *opaque, hwaddr addr, unsigned size)
         } else if (ch == 0) {
             return concat_reg(tmr->tcora);
         }
+        /* fall through */
     case A_TCORB:
         if (size == 1) {
             return tmr->tcorb[ch];

You fixed A_TCORA but not A_TCORB...

A_TCORB cannot fall through, since it always does a "return" in both branches of the if-statement.

However, it also looks really odd that A_TCORA falls through to A_TCORB here and return that register value instead. Is this really intended? Yoshinori, could you please double-check whether this is a bug here, or intended?

Thanks,
Thomas

#37 lore raw

Re: [PATCH 9/9] hw/timer/renesas_tmr: silence the compiler warnings

Quoted 39 lines · Thomas Huth
Quoted 21 lines · Philippe Mathieu-Daudé
Quoted 20 lines · Chen Qun

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
../hw/timer/renesas_tmr.c: In function ‘tmr_read’:
../hw/timer/renesas_tmr.c:221:19: warning: this statement may fall through [-Wimplicit-fallthrough=]
221 | } else if (ch == 0) {i
| ^
../hw/timer/renesas_tmr.c:224:5: note: here

  224 |     case A_TCORB:
      |     ^~~~

Add the corresponding "fall through" comment to fix it.

---
Cc: Yoshinori Sato <[email protected]>
Cc: Magnus Damm <[email protected]>

---
 hw/timer/renesas_tmr.c | 1 +
 1 file changed, 1 insertion(+)
Quoted 15 lines

hw/timer/renesas_tmr.c static uint64_t tmr_read(void *opaque, hwaddr addr, unsigned size) · line 227

Quoted 13 lines
hw/timer/renesas_tmr.c +1 -0
index 446f2eacdd..e03a8155b2 100644
@@ -221,6 +221,7 @@ static uint64_t tmr_read(void *opaque, hwaddr addr, unsigned size)
         } else if (ch == 0) {
             return concat_reg(tmr->tcora);
         }
+        /* fall through */
     case A_TCORB:
         if (size == 1) {
             return tmr->tcorb[ch];

You fixed A_TCORA but not A_TCORB...

Quoted 6 lines

A_TCORB cannot fall through, since it always does a "return" in both branches of the if-statement.

However, it also looks really odd that A_TCORA falls through to A_TCORB here and return that register value instead. Is this really intended? Yoshinori, could you please double-check whether this is a bug here, or intended?

See the discussion in this thread:
https://lore.kernel.org/qemu-devel/CAFEAcA8c2dywr=Zxz1ExAV-48JwFU5vbBDDfA=_KE98XamnXiA@mail.gmail.com/
from when Coverity spotting the fall-through.

I think this cleanup patch from Yoshinori deals with the fall-through stuff by cleaning up that area of the timer device:
https://lore.kernel.org/qemu-devel/[email protected]/
It just needs somebody to code-review it :-)

thanks
-- PMM

#38 lore raw

RE: [PATCH 9/9] hw/timer/renesas_tmr: silence the compiler warnings

Quoted 68 lines

-----Original Message-----
From: Peter Maydell [mailto:[email protected]]
Sent: Thursday, October 29, 2020 4:15 AM
To: Thomas Huth <[email protected]>
Cc: Philippe Mathieu-Daudé <[email protected]>; Chenqun (kuhn) <[email protected]>; QEMU Developers <[email protected]>; QEMU Trivial <[email protected]>; Yoshinori Sato <[email protected]>; Magnus Damm <[email protected]>; Zhanghailiang <[email protected]>; ganqixin <[email protected]>; Euler Robot <[email protected]>
Subject: Re: [PATCH 9/9] hw/timer/renesas_tmr: silence the compiler warnings

Quoted 4 lines · Thomas Huth
Quoted 2 lines · Philippe Mathieu-Daudé
Quoted 1 line · Chen Qun

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed

warning:

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

../hw/timer/renesas_tmr.c: In function ‘tmr_read’:
../hw/timer/renesas_tmr.c:221:19: warning: this statement may fall

through [-Wimplicit-fallthrough=]

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

221 | } else if (ch == 0) {i
| ^
../hw/timer/renesas_tmr.c:224:5: note: here

  224 |     case A_TCORB:
      |     ^~~~

Add the corresponding "fall through" comment to fix it.

---
Cc: Yoshinori Sato <[email protected]>
Cc: Magnus Damm <[email protected]>

---
 hw/timer/renesas_tmr.c | 1 +
 1 file changed, 1 insertion(+)
Quoted 5 lines
Quoted 5 lines

hw/timer/renesas_tmr.c static uint64_t tmr_read(void *opaque, hwaddr

Quoted 5 lines
hw/timer/renesas_tmr.c index renamed from hw/timer/renesas_tmr.c +0 -0

446f2eacdd..e03a8155b2 100644

hw/timer/renesas_tmr.c +0 -0
@@ -221,6 +221,7 @@ static uint64_t tmr_read(void *opaque, hwaddr

addr, unsigned size)

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
hw/timer/renesas_tmr.c +1 -0
         } else if (ch == 0) {
             return concat_reg(tmr->tcora);
         }
+        /* fall through */
     case A_TCORB:
         if (size == 1) {
             return tmr->tcorb[ch];
Quoted 8 lines
Quoted 1 line

You fixed A_TCORA but not A_TCORB...

A_TCORB cannot fall through, since it always does a "return" in both branches of the if-statement.

However, it also looks really odd that A_TCORA falls through to A_TCORB here and return that register value instead. Is this really intended? Yoshinori, could you please double-check whether this is a bug here,

or intended?

See the discussion in this thread:
https://lore.kernel.org/qemu-devel/CAFEAcA8c2dywr=Zxz1ExAV-48JwFU5vbBD
[email protected]/
from when Coverity spotting the fall-through.

Quoted 5 lines

I think this cleanup patch from Yoshinori deals with the fall-through stuff by cleaning up that area of the timer device:
https://lore.kernel.org/qemu-devel/[email protected]
urceforge.jp/
It just needs somebody to code-review it :-)

This cleanup patch has been modified more thoroughly, so let's wait for it merge :-)

Thanks,
Chen Qun

#39 lore raw

RE: [PATCH 9/9] hw/timer/renesas_tmr: silence the compiler warnings

In reply to Philippe Mathieu-Daudé
Quoted 49 lines

-----Original Message-----
From: Philippe Mathieu-Daudé [mailto:[email protected]] On Behalf Of Philippe Mathieu-Daudé
Sent: Wednesday, October 28, 2020 6:00 PM
To: Chenqun (kuhn) <[email protected]>; [email protected]; [email protected]
Cc: Zhanghailiang <[email protected]>; Yoshinori Sato <[email protected]>; Magnus Damm <[email protected]>; ganqixin <[email protected]>; Euler Robot <[email protected]>
Subject: Re: [PATCH 9/9] hw/timer/renesas_tmr: silence the compiler warnings

Quoted 1 line · Chen Qun

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed

warning:

Quoted 2 lines

../hw/timer/renesas_tmr.c: In function ‘tmr_read’:
../hw/timer/renesas_tmr.c:221:19: warning: this statement may fall through

[-Wimplicit-fallthrough=]

hw/timer/renesas_tmr.c static uint64_t tmr_read(void *opaque, hwaddr addr,

Quoted 22 lines

221 | } else if (ch == 0) {i
| ^
../hw/timer/renesas_tmr.c:224:5: note: here

  224 |     case A_TCORB:
      |     ^~~~

Add the corresponding "fall through" comment to fix it.

---
Cc: Yoshinori Sato <[email protected]>
Cc: Magnus Damm <[email protected]>

---
 hw/timer/renesas_tmr.c | 1 +
 1 file changed, 1 insertion(+)
hw/timer/renesas_tmr.c index renamed from hw/timer/renesas_tmr.c +0 -0

446f2eacdd..e03a8155b2 100644

hw/timer/renesas_tmr.c +0 -0
@@ -221,6 +221,7 @@ static uint64_t tmr_read(void *opaque, hwaddr addr,

unsigned size)

hw/timer/renesas_tmr.c static uint64_t tmr_read(void *opaque, hwaddr addr, unsigned size) · line 227

Quoted 8 lines
hw/timer/renesas_tmr.c +1 -0
         } else if (ch == 0) {
             return concat_reg(tmr->tcora);
         }
+        /* fall through */
     case A_TCORB:
         if (size == 1) {
             return tmr->tcorb[ch];
Quoted 2 lines

You fixed A_TCORA but not A_TCORB...

Hi Philippe,
My first feeling is the same as you when this warning found.
But, the number of branches for A_TCORA and A_TCORB is different.

In A_TCORA case:"} else if (ch == 0) {"
In A_TCORB case:"} else {"

Obviously, A_TCOB have all return values. But A_TCOA is not, it need to fall through or break.

Quoted 1 line

How the Euler Robot works? Like Coverity?

No, unlike Coverity, Coverity is essentially a good discovery bug tool.
But EulerRobot is a virtualization software quality automation project that integrates some tools and test suites such as gcc/clang make test, qemu ut, qtest, coccinelle scripts and avocado-vt.

Thanks,
Chen Qun