Skip to contentSkip to conversation

hw/rtc/twl92230: Add missing 'break'

PATCH In review Philippe Mathieu-Daudé 3 participants 3 messages Dec 11, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/rtc/twl92230: Add missing 'break'

Add missing 'break' to fix:

hw/rtc/twl92230.c: In function ‘menelaus_write’:
hw/rtc/twl92230.c:713:5: error: label at end of compound statement

    713 |     default:
        |     ^~~~~~~

---
I noticed Thomas "Compile QEMU with -Wimplicit-fallthrough" series and remembered this old patch.

---
 hw/rtc/twl92230.c | 1 +
 1 file changed, 1 insertion(+)
hw/rtc/twl92230.c +1 -0
index f838913b378..28656cb0e59 100644
@@ -714,6 +714,7 @@ static void menelaus_write(void *opaque, uint8_t addr, uint8_t value)
 #ifdef VERBOSE
         printf("%s: unknown register %02x\n", __func__, addr);
 #endif
+        break;
     }
 }
 
Signature · 1 line
2.26.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Philippe Mathieu-Daudé

Add missing 'break' to fix:

hw/rtc/twl92230.c: In function ‘menelaus_write’:
hw/rtc/twl92230.c:713:5: error: label at end of compound statement

    713 |     default:
        |     ^~~~~~~
Quoted 8 lines

---
I noticed Thomas "Compile QEMU with -Wimplicit-fallthrough" series and remembered this old patch.

---
 hw/rtc/twl92230.c | 1 +
 1 file changed, 1 insertion(+)

I guess the compiler doesn't care about missing 'break' in the last case in a switch statement. But I think putting in the 'break' is better style anyway.

thanks
-- PMM

Reviewed-by on v1 1/1
#2 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 6 lines · Philippe Mathieu-Daudé

Add missing 'break' to fix:

hw/rtc/twl92230.c: In function ‘menelaus_write’:
hw/rtc/twl92230.c:713:5: error: label at end of compound statement

    713 |     default:
        |     ^~~~~~~

... which occurs when disabling the "VERBOSE" switch in this file (that is enabled by default - that's why we've not noticed this before).

Quoted 14 lines

---
I noticed Thomas "Compile QEMU with -Wimplicit-fallthrough" series and remembered this old patch.

---
 hw/rtc/twl92230.c | 1 +
 1 file changed, 1 insertion(+)
hw/rtc/twl92230.c +0 -0
index f838913b378..28656cb0e59 100644

hw/rtc/twl92230.c static void menelaus_write(void *opaque, uint8_t addr, uint8_t value) · line 719

Quoted 6 lines
hw/rtc/twl92230.c +1 -0
@@ -714,6 +714,7 @@ static void menelaus_write(void *opaque, uint8_t addr, uint8_t value)
 #ifdef VERBOSE
         printf("%s: unknown register %02x\n", __func__, addr);
 #endif
+        break;
     }
 }