From patchwork Wed Aug 1 15:45:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 174473 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id C0F062C0087 for ; Thu, 2 Aug 2012 01:45:35 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755325Ab2HAPpa (ORCPT ); Wed, 1 Aug 2012 11:45:30 -0400 Received: from smtp.gentoo.org ([140.211.166.183]:51057 "EHLO smtp.gentoo.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751084Ab2HAPp3 (ORCPT ); Wed, 1 Aug 2012 11:45:29 -0400 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id A5CDE1B4011; Wed, 1 Aug 2012 15:45:28 +0000 (UTC) From: Mike Frysinger To: YOSHIFUJI Hideaki Cc: netdev@vger.kernel.org Subject: [PATCH 1/6] tracepath: re-use printf return in print_host Date: Wed, 1 Aug 2012 11:45:23 -0400 Message-Id: <1343835928-21541-1-git-send-email-vapier@gentoo.org> X-Mailer: git-send-email 1.7.9.7 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- tracepath.c | 11 ++++------- tracepath6.c | 11 ++++------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/tracepath.c b/tracepath.c index bcec20d..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) { - 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 0cbe3a1..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) { - 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, "");