netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH [iputils] 1/6] tracepath: re-use printf return in print_host
@ 2013-01-25  5:24 Mike Frysinger
  2013-01-25  5:24 ` [PATCH [iputils] 2/6] ping: fix building on older systems Mike Frysinger
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Mike Frysinger @ 2013-01-25  5:24 UTC (permalink / raw)
  To: YOSHIFUJI Hideaki; +Cc: netdev

Since the printf funcs already return the length of chars displayed,
use that value instead of re-calculating the length with strlen.

This also fixes the handling of the strlen return -- it's a size_t,
not an int.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 tracepath.c  | 11 ++++-------
 tracepath6.c | 11 ++++-------
 2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/tracepath.c b/tracepath.c
index 8a08f1d..f155816 100644
--- a/tracepath.c
+++ b/tracepath.c
@@ -73,13 +73,10 @@ void data_wait(int fd)
 
 void print_host(const char *a, const char *b, int both)
 {
-	int plen = 0;
-	printf("%s", a);
-	plen = strlen(a);
-	if (both) {
-		printf(" (%s)", b);
-		plen += strlen(b) + 3;
-	}
+	int plen;
+	plen = printf("%s", a);
+	if (both)
+		plen += printf(" (%s)", b);
 	if (plen >= HOST_COLUMN_SIZE)
 		plen = HOST_COLUMN_SIZE - 1;
 	printf("%*s", HOST_COLUMN_SIZE - plen, "");
diff --git a/tracepath6.c b/tracepath6.c
index 126fadf..bee95c3 100644
--- a/tracepath6.c
+++ b/tracepath6.c
@@ -86,13 +86,10 @@ void data_wait(int fd)
 
 void print_host(const char *a, const char *b, int both)
 {
-	int plen = 0;
-	printf("%s", a);
-	plen = strlen(a);
-	if (both) {
-		printf(" (%s)", b);
-		plen += strlen(b) + 3;
-	}
+	int plen;
+	plen = printf("%s", a);
+	if (both)
+		plen += printf(" (%s)", b);
 	if (plen >= HOST_COLUMN_SIZE)
 		plen = HOST_COLUMN_SIZE - 1;
 	printf("%*s", HOST_COLUMN_SIZE - plen, "");
-- 
1.8.0.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-01-25  5:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-25  5:24 [PATCH [iputils] 1/6] tracepath: re-use printf return in print_host Mike Frysinger
2013-01-25  5:24 ` [PATCH [iputils] 2/6] ping: fix building on older systems Mike Frysinger
2013-01-25  5:24 ` [PATCH [iputils] 3/6] start gitignore files Mike Frysinger
2013-01-25  5:24 ` [PATCH [iputils] 4/6] doc: fix parallel build of html/man pages Mike Frysinger
2013-01-25  5:24 ` [PATCH [iputils] 5/6] ping6: allow disabling of openssl support Mike Frysinger
2013-01-25  5:24 ` [PATCH [iputils] 6/6] fix handling of CFLAGS Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).