]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/ttyutils: avoid checking same thing twice
authorSami Kerola <kerolasa@iki.fi>
Mon, 1 Jul 2019 21:02:06 +0000 (22:02 +0100)
committerSami Kerola <kerolasa@iki.fi>
Mon, 1 Jul 2019 21:02:06 +0000 (22:02 +0100)
Check cols and lines are not NULL only once.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
lib/ttyutils.c

index 166e49e11a1e0e975aa02d441856e52617ce9960..8649f435aedac0c78ab45f9ead4548539fda1fe4 100644 (file)
@@ -47,16 +47,16 @@ int get_terminal_dimension(int *cols, int *lines)
                l = t_win.ts_lines;
        }
 #endif
-
-       if (cols && c <= 0)
-               c = get_env_int("COLUMNS");
-       if (lines && l <= 0)
-               l = get_env_int("LINES");
-
-       if (cols)
+       if (cols) {
+               if (c <= 0)
+                       c = get_env_int("COLUMNS");
                *cols = c;
-       if (lines)
+       }
+       if (lines) {
+               if (l <= 0)
+                       l = get_env_int("LINES");
                *lines = l;
+       }
        return 0;
 }