Commit e8f2a139 authored by Jiri Slaby's avatar Jiri Slaby Committed by Greg Kroah-Hartman
Browse files

n_tty: invert TTY_NORMAL condition in n_tty_receive_buf_standard



Handle !TTY_NORMAL as a short path and 'continue' the loop. Do the rest as
a normal code flow. This decreases the indentation level by one and
makes the code flow more understandable.

IOW, we avoid
  if (cond) {
    LONG CODE;
  } else
    single_line();
by
  if (!cond) {
    single_line();
    continue;
  }
  LONG CODE;

While at it, invert also the 'if (!test_bit) A else B' into 'if
(test_bit) B else A'.

Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210505091928.22010-10-jslaby@suse.cz


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3a7d530a
Loading
Loading
Loading
Loading
+17 −14
Original line number Diff line number Diff line
@@ -1541,7 +1541,11 @@ static void n_tty_receive_buf_standard(struct tty_struct *tty,
			continue;
		}

		if (likely(flag == TTY_NORMAL)) {
		if (unlikely(flag != TTY_NORMAL)) {
			n_tty_receive_char_flagged(tty, c, flag);
			continue;
		}

		if (I_ISTRIP(tty))
			c &= 0x7f;
		if (I_IUCLC(tty) && L_IEXTEN(tty))
@@ -1550,12 +1554,11 @@ static void n_tty_receive_buf_standard(struct tty_struct *tty,
			put_tty_queue(c, ldata);
			continue;
		}
			if (!test_bit(c, ldata->char_map))
				n_tty_receive_char(tty, c);
			else

		if (test_bit(c, ldata->char_map))
			n_tty_receive_char_special(tty, c);
		} else
			n_tty_receive_char_flagged(tty, c, flag);
		else
			n_tty_receive_char(tty, c);
	}
}