[PATCH] hw/rtc/twl92230: Add missing 'break'

Philippe Mathieu-Daudé posted 1 patch 3 years, 4 months ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20201211154605.511714-1-f4bug@amsat.org
hw/rtc/twl92230.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] hw/rtc/twl92230: Add missing 'break'
Posted by Philippe Mathieu-Daudé 3 years, 4 months ago
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:
        |     ^~~~~~~

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
I noticed Thomas "Compile QEMU with -Wimplicit-fallthrough" series
and remembered this old patch.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/rtc/twl92230.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/rtc/twl92230.c b/hw/rtc/twl92230.c
index f838913b378..28656cb0e59 100644
--- a/hw/rtc/twl92230.c
+++ b/hw/rtc/twl92230.c
@@ -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;
     }
 }
 
-- 
2.26.2

Re: [PATCH] hw/rtc/twl92230: Add missing 'break'
Posted by Peter Maydell 3 years, 4 months ago
On Fri, 11 Dec 2020 at 15:46, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> 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:
>         |     ^~~~~~~
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> I noticed Thomas "Compile QEMU with -Wimplicit-fallthrough" series
> and remembered this old patch.
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  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.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM

Re: [PATCH] hw/rtc/twl92230: Add missing 'break'
Posted by Thomas Huth 3 years, 4 months ago
On 11/12/2020 16.46, Philippe Mathieu-Daudé wrote:
> 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).

> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> I noticed Thomas "Compile QEMU with -Wimplicit-fallthrough" series
> and remembered this old patch.
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  hw/rtc/twl92230.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/hw/rtc/twl92230.c b/hw/rtc/twl92230.c
> index f838913b378..28656cb0e59 100644
> --- a/hw/rtc/twl92230.c
> +++ b/hw/rtc/twl92230.c
> @@ -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;
>      }
>  }

Reviewed-by: Thomas Huth <thuth@redhat.com>