[PATCH 1/1] lib: missing fallthrough comment in vsnprintf_internal()

Simon Glass sjg at chromium.org
Sun Apr 2 04:37:40 CEST 2023


Hi Heinrich,

On Sat, 1 Apr 2023 at 19:13, Heinrich Schuchardt <
heinrich.schuchardt at canonical.com> wrote:
>
> When a case statement intentionally falls through we should add a comment.
> Cf. -Wimplicit-fallthrough
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
> ---
>  lib/vsprintf.c | 4 ++++
>  1 file changed, 4 insertions(+)

Why not use the fallthrough macro here?

>
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index 2d13e68b57..8af6310651 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -674,6 +674,7 @@ repeat:
>
>                 case 'x':
>                         flags |= SMALL;
> +               /* fallthrough */
>                 case 'X':
>                         base = 16;
>                         break;
> @@ -681,8 +682,10 @@ repeat:
>                 case 'd':
>                         if (fmt[1] == 'E')
>                                 flags |= ERRSTR;
> +               /* fallthrough */
>                 case 'i':
>                         flags |= SIGN;
> +               /* fallthrough */
>                 case 'u':
>                         break;
>
> --
> 2.39.2
>

Regards,
Simon


More information about the U-Boot mailing list