lkml.org 
[lkml]   [2021]   [May]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 09/35] n_tty: invert TTY_NORMAL condition in n_tty_receive_buf_standard
    Date
    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: Jiri Slaby <jslaby@suse.cz>
    ---
    drivers/tty/n_tty.c | 31 +++++++++++++++++--------------
    1 file changed, 17 insertions(+), 14 deletions(-)

    diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
    index e7c9dce14f88..01883e5c8bbd 100644
    --- a/drivers/tty/n_tty.c
    +++ b/drivers/tty/n_tty.c
    @@ -1541,21 +1541,24 @@ static void n_tty_receive_buf_standard(struct tty_struct *tty,
    continue;
    }

    - if (likely(flag == TTY_NORMAL)) {
    - if (I_ISTRIP(tty))
    - c &= 0x7f;
    - if (I_IUCLC(tty) && L_IEXTEN(tty))
    - c = tolower(c);
    - if (L_EXTPROC(tty)) {
    - put_tty_queue(c, ldata);
    - continue;
    - }
    - if (!test_bit(c, ldata->char_map))
    - n_tty_receive_char(tty, c);
    - else
    - n_tty_receive_char_special(tty, c);
    - } else
    + 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))
    + c = tolower(c);
    + if (L_EXTPROC(tty)) {
    + put_tty_queue(c, ldata);
    + continue;
    + }
    +
    + if (test_bit(c, ldata->char_map))
    + n_tty_receive_char_special(tty, c);
    + else
    + n_tty_receive_char(tty, c);
    }
    }

    --
    2.31.1
    \
     
     \ /
      Last update: 2021-05-05 11:21    [W:2.071 / U:0.052 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site