From f1300e2cea31d6232783dafb97b7c600d48823e8 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 22 Mar 2015 23:05:26 +0000 Subject: dmesg: fix shadow declaration 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 --- sys-utils/dmesg.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'sys-utils/dmesg.c') diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c index 5a6ee41d9..b56199f36 100644 --- a/sys-utils/dmesg.c +++ b/sys-utils/dmesg.c @@ -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; -- cgit v1.2.3-55-g7522