Re: [PATCH] ASN.1: mark expected switch fall-throughs

From: Kees Cook
Date: Fri Jan 25 2019 - 19:38:37 EST


On Sat, Jan 26, 2019 at 9:49 AM Gustavo A. R. Silva
<gustavo@xxxxxxxxxxxxxx> wrote:
>
> In preparation to enabling -Wimplicit-fallthrough, mark switch
> cases where we are expecting to fall through.
>
> This patch fixes the following warnings:
>
> lib/asn1_decoder.c:386:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
> lib/asn1_decoder.c:449:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
>
> Warning level 3 was used: -Wimplicit-fallthrough=3
>
> This patch is part of the ongoing efforts to enabling
> -Wimplicit-fallthrough.
>
> Signed-off-by: Gustavo A. R. Silva <gustavo@xxxxxxxxxxxxxx>

Reviewed-by: Kees Cook <keescook@xxxxxxxxxxxx>

-Kees

> ---
> lib/asn1_decoder.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/lib/asn1_decoder.c b/lib/asn1_decoder.c
> index dc14beae2c9a..8f3d207d2b00 100644
> --- a/lib/asn1_decoder.c
> +++ b/lib/asn1_decoder.c
> @@ -385,6 +385,8 @@ int asn1_ber_decoder(const struct asn1_decoder *decoder,
> case ASN1_OP_END_SET_ACT:
> if (unlikely(!(flags & FLAG_MATCHED)))
> goto tag_mismatch;
> + /* fall through */
> +
> case ASN1_OP_END_SEQ:
> case ASN1_OP_END_SET_OF:
> case ASN1_OP_END_SEQ_OF:
> @@ -450,6 +452,8 @@ int asn1_ber_decoder(const struct asn1_decoder *decoder,
> pc += asn1_op_lengths[op];
> goto next_op;
> }
> + /* fall through */
> +
> case ASN1_OP_ACT:
> ret = actions[machine[pc + 1]](context, hdr, tag, data + tdp, len);
> if (ret < 0)
> --
> 2.20.1
>


--
Kees Cook