OSDN Git Service

blkid: fix blkid -o list formatting with columns > 160
authorTheodore Ts'o <tytso@mit.edu>
Sat, 11 Jan 2014 04:25:54 +0000 (23:25 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 11 Jan 2014 04:25:54 +0000 (23:25 -0500)
This bug is also in the util-linux version of blkid.

Addresses-Coverity-Id: #1049158

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
misc/blkid.c

index 2e48caa..c40de98 100644 (file)
@@ -142,20 +142,21 @@ static void pretty_print_line(const char *device, const char *fs_type,
        static int term_width = -1;
        int len, w;
 
-       if (term_width < 0)
+       if (term_width < 0) {
                term_width = get_terminal_width();
 
-       if (term_width > 80) {
-               term_width -= 80;
-               w = term_width / 10;
-               if (w > 8)
-                       w = 8;
-               term_width -= 2*w;
-               label_len += w;
-               fs_type_len += w;
-               w = term_width/2;
-               device_len += w;
-               mtpt_len +=w;
+               if (term_width > 80) {
+                       term_width -= 80;
+                       w = term_width / 10;
+                       if (w > 8)
+                               w = 8;
+                       term_width -= 2*w;
+                       label_len += w;
+                       fs_type_len += w;
+                       w = term_width/2;
+                       device_len += w;
+                       mtpt_len +=w;
+               }
        }
 
        len = pretty_print_word(device, device_len, 0, 1);