aboutsummaryrefslogtreecommitdiffstats
path: root/main/iputils/net-misc_iputils_files_iputils-20121221-printf-size.patch
blob: 6d6c3b7d258045ba1d8347de265dc4518d37f7c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
From 23fcb10ae15a96aa9e5a823cfe0b612d9522691c Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Sat, 14 Aug 2010 01:16:42 -0400
Subject: [PATCH [iputils]] tracepath: re-use printf return in print_host

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