[PATCH] app: fix gcc 12 array bounds warning

wenxuanx.wu at intel.com wenxuanx.wu at intel.com
Thu Jun 16 12:26:13 CEST 2022


From: Wenxuan Wu <wenxuanx.wu at intel.com>

when n == 1000, and it would be overflow the array size of 4 bytes with
nul terminator. Change the logic to avoid this warning.

Fixes: 15c431864000 ("app/flow-perf: add packet forwarding support")
Cc: stable at dpdk.org
Signed-off-by: Wenxuan Wu <wenxuanx.wu at intel.com>
---
 app/test-flow-perf/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/test-flow-perf/main.c b/app/test-flow-perf/main.c
index 56d43734e3..661d562158 100644
--- a/app/test-flow-perf/main.c
+++ b/app/test-flow-perf/main.c
@@ -1728,7 +1728,7 @@ pretty_number(uint64_t n, char *buf)
 	int i = 0;
 	int off = 0;
 
-	while (n > 1000) {
+	while (n >= 1000) {
 		sprintf(p[i], "%03d", (int)(n % 1000));
 		n /= 1000;
 		i += 1;
-- 
2.25.1



More information about the stable mailing list