From: Mike Frysinger <vapier@gentoo.org>
To: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Cc: netdev@vger.kernel.org
Subject: [PATCH 1/3] tracepath: re-use printf return in print_host
Date: Sat, 19 Feb 2011 12:51:27 -0500 [thread overview]
Message-ID: <1298137889-23969-1-git-send-email-vapier@gentoo.org> (raw)
The printf funcs take an int for field widths, not a size_t. Also, since
the printf funcs already return the length of chars displayed, use that
value instead of re-calculating the length with strlen.
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 81c22e9..ca84a69 100644
--- a/tracepath.c
+++ b/tracepath.c
@@ -68,13 +68,10 @@ void data_wait(int fd)
void print_host(const char *a, const char *b, int both)
{
- size_t 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 5cc7424..5c2db8f 100644
--- a/tracepath6.c
+++ b/tracepath6.c
@@ -80,13 +80,10 @@ void data_wait(int fd)
void print_host(const char *a, const char *b, int both)
{
- size_t 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.7.4.1
next reply other threads:[~2011-02-19 17:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-19 17:51 Mike Frysinger [this message]
2011-02-19 17:51 ` [PATCH 2/3] fix up strict-aliasing warnings Mike Frysinger
2011-02-19 17:51 ` [PATCH 3/3] tracepath: fix typo in -l error message Mike Frysinger
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=1298137889-23969-1-git-send-email-vapier@gentoo.org \
--to=vapier@gentoo.org \
--cc=netdev@vger.kernel.org \
--cc=yoshfuji@linux-ipv6.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