n_tty: do only one cp dereference in n_tty_receive_buf_standard
authorJiri Slaby <jslaby@suse.cz>
Wed, 5 May 2021 09:19:01 +0000 (11:19 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 May 2021 14:57:16 +0000 (16:57 +0200)
It might be confusing for readers: there are three distinct dereferences
and increments of 'cp' in n_tty_receive_buf_standard. Do it on a single
place, along with/before the 'fp' dereference.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210505091928.22010-9-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/n_tty.c

index b8f981499465a4c46d3e5429dc5fc2e572c14dcf..e7c9dce14f88be68e49241cb800b377afe51e7d9 100644 (file)
@@ -1531,17 +1531,17 @@ static void n_tty_receive_buf_standard(struct tty_struct *tty,
        char flag = TTY_NORMAL;
 
        while (count--) {
+               unsigned char c = *cp++;
+
                if (fp)
                        flag = *fp++;
 
                if (ldata->lnext) {
-                       n_tty_receive_char_lnext(tty, *cp++, flag);
+                       n_tty_receive_char_lnext(tty, c, flag);
                        continue;
                }
 
                if (likely(flag == TTY_NORMAL)) {
-                       unsigned char c = *cp++;
-
                        if (I_ISTRIP(tty))
                                c &= 0x7f;
                        if (I_IUCLC(tty) && L_IEXTEN(tty))
@@ -1555,7 +1555,7 @@ static void n_tty_receive_buf_standard(struct tty_struct *tty,
                        else
                                n_tty_receive_char_special(tty, c);
                } else
-                       n_tty_receive_char_flagged(tty, *cp++, flag);
+                       n_tty_receive_char_flagged(tty, c, flag);
        }
 }