From patchwork Fri Jun 10 22:06:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rahul Lakkireddy X-Patchwork-Id: 112670 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id F0BF3A054F; Sat, 11 Jun 2022 00:07:11 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 58E4B4069C; Sat, 11 Jun 2022 00:07:11 +0200 (CEST) Received: from stargate.chelsio.com (stargate.chelsio.com [12.32.117.8]) by mails.dpdk.org (Postfix) with ESMTP id DE17D40041; Sat, 11 Jun 2022 00:07:09 +0200 (CEST) Received: from localhost (sicon-nithya-lt.asicdesigners.com [10.193.177.181] (may be forged)) by stargate.chelsio.com (8.14.7/8.14.7) with ESMTP id 25AM77uR016668; Fri, 10 Jun 2022 15:07:08 -0700 From: Rahul Lakkireddy To: dev@dpdk.org Cc: daxuex.gao@intel.com, wisamm@nvidia.com, stable@dpdk.org Subject: [PATCH] app/flow-perf: fix logic to add comma every three digits Date: Sat, 11 Jun 2022 03:36:43 +0530 Message-Id: <08953a79d2cf9a91cc687a25b964c52cf6bb3e09.1654898425.git.rahul.lakkireddy@chelsio.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Add comma after 1 in 1000 too, like 1,000. Also, since max uint64_t is a 20 digit number, increase space in temporary array to hold 20 digits. Fixes following warnings when using optimization=1 build flag with GCC 11. ../app/test-flow-perf/main.c: In function ‘pretty_number’: ../app/test-flow-perf/main.c:1737:28: warning: ‘sprintf’ may write a terminating nul past the end of the destination [-Wformat-overflow=] sprintf(p[i++], "%d", (int)n); ^ ../app/test-flow-perf/main.c:1737:9: note: ‘sprintf’ output between 2 and 5 bytes into a destination of size 4 sprintf(p[i++], "%d", (int)n); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Bugzilla ID: 1029 Fixes: 15c431864000 ("app/flow-perf: add packet forwarding support") Cc: stable@dpdk.org Reported-by: Daxue Gao Signed-off-by: Rahul Lakkireddy --- app/test-flow-perf/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/test-flow-perf/main.c b/app/test-flow-perf/main.c index 56d43734e3..594507a85e 100644 --- a/app/test-flow-perf/main.c +++ b/app/test-flow-perf/main.c @@ -1724,11 +1724,11 @@ do_tx(struct lcore_info *li, uint16_t cnt, uint16_t tx_port, static char * pretty_number(uint64_t n, char *buf) { - char p[6][4]; + char p[7][4]; int i = 0; int off = 0; - while (n > 1000) { + while (n >= 1000) { sprintf(p[i], "%03d", (int)(n % 1000)); n /= 1000; i += 1;