Util-Linux package development
 help / color / mirror / Atom feed
From: Sami Kerola <kerolasa@iki.fi>
To: util-linux@vger.kernel.org
Cc: Sami Kerola <kerolasa@iki.fi>
Subject: [PATCH 1/5] dmesg: fix shadow declaration
Date: Sun, 22 Mar 2015 23:05:26 +0000	[thread overview]
Message-ID: <1427065530-10695-2-git-send-email-kerolasa@iki.fi> (raw)
In-Reply-To: <1427065530-10695-1-git-send-email-kerolasa@iki.fi>

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 | 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


  reply	other threads:[~2015-03-22 23:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-22 23:05 [PATCH 0/5] pull: one dmesg compiler warning fix and bunch of tests Sami Kerola
2015-03-22 23:05 ` Sami Kerola [this message]
2015-03-22 23:05 ` [PATCH 2/5] tests: add dmesg multiline message check Sami Kerola
2015-03-22 23:05 ` [PATCH 3/5] tests: add test_dmesg that has fixed boot time Sami Kerola
2015-03-22 23:05 ` [PATCH 4/5] tests: check timestamp formats Sami Kerola
2015-03-22 23:05 ` [PATCH 5/5] tests: check dmesg message coloring Sami Kerola
2015-03-23 10:44 ` [PATCH 0/5] pull: one dmesg compiler warning fix and bunch of tests Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1427065530-10695-2-git-send-email-kerolasa@iki.fi \
    --to=kerolasa@iki.fi \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox