@@ -68,13 +68,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, "");
@@ -80,13 +80,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, "");
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(-)