[PATCH 1/5] dmesg: fix shadow declaration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx>
---
 sys-utils/dmesg.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c
index 5a6ee41..b56199f 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;
-- 
2.3.3

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux