Re: [PATCH] n_tty: Distribute switch variables for initialization

From: Jiri Slaby
Date: Thu Feb 20 2020 - 03:26:04 EST


On 20. 02. 20, 7:23, Kees Cook wrote:
> Note that these warnings (or silent
> skipping) happen before the dead-store elimination optimization phase,
> so even when the automatic initializations are later elided in favor of
> direct initializations, the warnings remain.

That is a compiler bug IMO, but OK, the move makes sense anyway.

> To avoid these problems, move such variables into the "case" where
> they're used or lift them up into the main function body.
...
> Signed-off-by: Kees Cook <keescook@xxxxxxxxxxxx>

Reviewed-by: Jiri Slaby <jslaby@xxxxxxx>

> ---
> drivers/tty/n_tty.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
> index f9c584244f72..1d1a398f4981 100644
> --- a/drivers/tty/n_tty.c
> +++ b/drivers/tty/n_tty.c
> @@ -654,9 +654,9 @@ static size_t __process_echoes(struct tty_struct *tty)
> op = echo_buf(ldata, tail + 1);
>
> switch (op) {
> + case ECHO_OP_ERASE_TAB: {
> unsigned int num_chars, num_bs;
>
> - case ECHO_OP_ERASE_TAB:
> if (MASK(ldata->echo_commit) == MASK(tail + 2))
> goto not_yet_stored;
> num_chars = echo_buf(ldata, tail + 2);
> @@ -687,7 +687,7 @@ static size_t __process_echoes(struct tty_struct *tty)
> }
> tail += 3;
> break;
> -
> + }
> case ECHO_OP_SET_CANON_COL:
> ldata->canon_column = ldata->column;
> tail += 2;
>

thanks,
--
js
suse labs