]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
dmesg: fix shadow declaration
authorSami Kerola <kerolasa@iki.fi>
Sun, 22 Mar 2015 23:05:26 +0000 (23:05 +0000)
committerKarel Zak <kzak@redhat.com>
Wed, 29 Apr 2015 10:22:44 +0000 (12:22 +0200)
sys-utils/dmesg.c:650:9: warning: declaration of 's' shadows a previous local [-Wshadow]
sys-utils/dmesg.c:619:12: warning: shadowed declaration is here [-Wshadow]

And since the code had to be touched deprecate loop printing one character
at a time, in favour of printf and instruction to repeat spaces the number
required.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
sys-utils/dmesg.c

index 5a6ee41d95bc4d1873d3887157251e4a8bd885df..b56199f36bac069b8d29ba7066e61c4a561dc93d 100644 (file)
@@ -614,7 +614,6 @@ static int fwrite_hex(const char *buf, size_t size, FILE *out)
 static void safe_fwrite(const char *buf, size_t size, int indent, FILE *out)
 {
        size_t i;
-       int in;
 #ifdef HAVE_WIDECHAR
        mbstate_t s;
        memset(&s, 0, sizeof (s));
@@ -647,13 +646,9 @@ static void safe_fwrite(const char *buf, size_t size, int indent, FILE *out)
                if (hex)
                        rc = fwrite_hex(p, len, out);
                else if (*p == '\n' && *(p + 1) && indent) {
-                       char s = ' ';
-                       rc = fwrite(p, 1, len, out) != len;
-                       in = indent;
-                       do {
-                               if (!rc) rc = fwrite(&s, 1, 1, out) != 1;
-                               in--;
-                       } while (in && !rc);
+                       rc = fwrite(p, 1, len, out) != len;
+                       if (fprintf(out, "%*s", indent, "") != indent)
+                               rc |= 1;
                }
                else
                        rc = fwrite(p, 1, len, out) != len;