[PATCH v11 1/6] test: increase size of memzone name

Stephen Hemminger
2026-01-17T02:38:30Z

The tests were using a name buffer of 20 characters which could
overflow if number of memory zones got large. The upper limit
is defined as RTE_MEMZONE_NAMESIZE so use that.

In function ‘test_memzone_free’,
inlined from ‘test_memzone’ at ../app/test/test_memzone.c:1117:6:
../app/test/test_memzone.c:52:35: warning: ‘%u’ directive output may be truncated writing between 1 and 10 bytes into a region of size 4 [-Wformat-truncation=]
52 | #define TEST_MEMZONE_NAME(suffix) "MZ_TEST_" suffix
| ^~~~~~~~~~
../app/test/test_memzone.c:931:46: note: in expansion of macro ‘TEST_MEMZONE_NAME’
931 | snprintf(name, sizeof(name), TEST_MEMZONE_NAME("tempzone%u"),
| ^~~~~~~~~~~~~~~~~
../app/test/test_memzone.c:52:35: note: directive argument in the range [0, 2147483647]
52 | #define TEST_MEMZONE_NAME(suffix) "MZ_TEST_" suffix
| ^~~~~~~~~~
../app/test/test_memzone.c:931:46: note: in expansion of macro ‘TEST_MEMZONE_NAME’
931 | snprintf(name, sizeof(name), TEST_MEMZONE_NAME("tempzone%u"),
| ^~~~~~~~~~~~~~~~~
../app/test/test_memzone.c:931:17: note: ‘snprintf’ output between 18 and 27 bytes into a destination of size 20
931 | snprintf(name, sizeof(name), TEST_MEMZONE_NAME("tempzone%u"),
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
932 | i);
|

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
app/test/test_memzone.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/test/test_memzone.c b/app/test/test_memzone.c
index 5094d15159..8712690561 100644
--- a/app/test/test_memzone.c
+++ b/app/test/test_memzone.c
@@ -872,7 +872,7 @@ test_memzone_free(void)
{
const struct rte_memzone **mz;
int i;
- char name[20];
+ char name[RTE_MEMZONE_NAMESIZE];
int rc = -1;

mz = rte_calloc("memzone_test", rte_memzone_max_get() + 1,
--
2.51.0