On 28/10/2020 05.18, Chen Qun wrote:
> 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.
> 
> Reported-by: Euler Robot <euler.ro...@huawei.com>
> Signed-off-by: Chen Qun <kuhn.chen...@huawei.com>
> ---
> Cc: Riku Voipio <riku.voi...@iki.fi>
> Cc: Richard Henderson <richard.hender...@linaro.org>
> Cc: Paolo Bonzini <pbonz...@redhat.com>
> ---
>  accel/tcg/user-exec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c
> index 4ebe25461a..330468e990 100644
> --- a/accel/tcg/user-exec.c
> +++ b/accel/tcg/user-exec.c
> @@ -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


Reply via email to