s390/tty3270: use switch/case in tty3270_erase_display()
authorSven Schnelle <svens@linux.ibm.com>
Sun, 27 Nov 2022 08:26:24 +0000 (09:26 +0100)
committerHeiko Carstens <hca@linux.ibm.com>
Mon, 9 Jan 2023 13:33:57 +0000 (14:33 +0100)
This makes the code easier to read.

Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Tested-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
drivers/s390/char/con3270.c

index 90671dd..84e8e07 100644 (file)
@@ -1337,25 +1337,29 @@ static void tty3270_erase_line(struct tty3270 *tp, int mode)
  */
 static void tty3270_erase_display(struct tty3270 *tp, int mode)
 {
-       int i;
+       int i, start, end;
 
-       if (mode == 0) {
+       switch (mode) {
+       case 0:
                tty3270_erase_line(tp, 0);
-               for (i = tp->cy + 1; i < tp->view.rows - 2; i++) {
-                       tp->screen[i].len = 0;
-                       tty3270_convert_line(tp, i);
-               }
-       } else if (mode == 1) {
-               for (i = 0; i < tp->cy; i++) {
-                       tp->screen[i].len = 0;
-                       tty3270_convert_line(tp, i);
-               }
+               start = tp->cy + 1;
+               end = tp->view.rows - 2;
+               break;
+       case 1:
+               start = 0;
+               end = tp->cy;
                tty3270_erase_line(tp, 1);
-       } else if (mode == 2) {
-               for (i = 0; i < tp->view.rows - 2; i++) {
-                       tp->screen[i].len = 0;
-                       tty3270_convert_line(tp, i);
-               }
+               break;
+       case 2:
+               start = 0;
+               end = tp->view.rows - 2;
+               break;
+       default:
+               return;
+       }
+       for (i = start; i < end; i++) {
+               tp->screen[i].len = 0;
+               tty3270_convert_line(tp, i);
        }
        tty3270_rebuild_update(tp);
 }