patch 'test/argparse: change initialization to workaround LTO' has been queued to stable release 24.11.4

Kevin Traynor ktraynor at redhat.com
Fri Oct 31 15:34:10 CET 2025


Hi,

FYI, your patch has been queued to stable release 24.11.4

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 11/05/25. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/kevintraynor/dpdk-stable

This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable/commit/6a73db92fbff3a64af61636b1b2557ef58c71319

Thanks.

Kevin

---
>From 6a73db92fbff3a64af61636b1b2557ef58c71319 Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <stephen at networkplumber.org>
Date: Tue, 9 Sep 2025 06:49:52 -0700
Subject: [PATCH] test/argparse: change initialization to workaround LTO
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

[ upstream commit 3fc246e883c412f3c285bcabdb402b7d66e78526 ]

When compiled with Link Time Optimization, the existing code
generated an error, because the compiler was unable to intuit
that there was space in the flexible array.

In function ‘test_argparse_copy’,
    inlined from ‘test_argparse_init_obj’
        at ../app/test/test_argparse.c:108:2,
    inlined from ‘test_argparse_opt_callback_parse_int_of_no_val’
        at ../app/test/test_argparse.c:490:8:
../app/test/test_argparse.c:96:17: warning:
‘memcpy’ writing 56 bytes into a region of size 0 overflows the destination
        memcpy(&dst->args[i], &src->args[i], sizeof(src->args[i]));

Initializing a structure with flexible array is special case
and compiler expands the structure to fit.
But inside the copy function it no longer knew that.

The workaround is to put the copy inside the same function
and use structure assignment. Also macro should be upper case.

Fixes: 6c5c6571601c ("argparse: verify argument config")

Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
Acked-by: Bruce Richardson <bruce.richardson at intel.com>
Acked-by: Chengwen Feng <fengchengwen at huawei.com>
---
 app/test/test_argparse.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/app/test/test_argparse.c b/app/test/test_argparse.c
index fcea620501..0ae54b2d64 100644
--- a/app/test/test_argparse.c
+++ b/app/test/test_argparse.c
@@ -72,5 +72,5 @@ test_argparse_callback(uint32_t index, const char *value, void *opaque)
 
 /* valid templater, must contain at least two args. */
-#define argparse_templater() { \
+#define ARGPARSE_TEMPLATE { \
 	.prog_name = "test_argparse", \
 	.usage = "-a xx -b yy", \
@@ -86,23 +86,22 @@ test_argparse_callback(uint32_t index, const char *value, void *opaque)
 }
 
-static void
-test_argparse_copy(struct rte_argparse *dst, struct rte_argparse *src)
-{
-	uint32_t i;
-	memcpy(dst, src, sizeof(*src));
-	for (i = 0; /* NULL */; i++) {
-		memcpy(&dst->args[i], &src->args[i], sizeof(src->args[i]));
-		if (src->args[i].name_long == NULL)
-			break;
-	}
-}
 
 static struct rte_argparse *
 test_argparse_init_obj(void)
 {
-	static struct rte_argparse backup = argparse_templater();
-	static struct rte_argparse obj = argparse_templater();
-	/* Because obj may be overwritten, do a deep copy. */
-	test_argparse_copy(&obj, &backup);
+	/* Note: initialization of structure with flexible array
+	 * increases the size of the variable to match.
+	 */
+	static const struct rte_argparse backup = ARGPARSE_TEMPLATE;
+	static struct rte_argparse obj = ARGPARSE_TEMPLATE;
+	unsigned int i;
+
+	obj = backup;
+	for (i = 0; ; i++) {
+		obj.args[i] = backup.args[i];
+		if (backup.args[i].name_long == NULL)
+			break;
+	}
+
 	return &obj;
 }
-- 
2.51.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2025-10-31 13:53:56.071408968 +0000
+++ 0128-test-argparse-change-initialization-to-workaround-LT.patch	2025-10-31 13:53:52.325524270 +0000
@@ -1 +1 @@
-From 3fc246e883c412f3c285bcabdb402b7d66e78526 Mon Sep 17 00:00:00 2001
+From 6a73db92fbff3a64af61636b1b2557ef58c71319 Mon Sep 17 00:00:00 2001
@@ -8,0 +9,2 @@
+[ upstream commit 3fc246e883c412f3c285bcabdb402b7d66e78526 ]
+
@@ -30 +31,0 @@
-Cc: stable at dpdk.org
@@ -40 +41 @@
-index 71a85ea960..d3b95c4e35 100644
+index fcea620501..0ae54b2d64 100644
@@ -43 +44 @@
-@@ -73,5 +73,5 @@ test_argparse_callback(uint32_t index, const char *value, void *opaque)
+@@ -72,5 +72,5 @@ test_argparse_callback(uint32_t index, const char *value, void *opaque)
@@ -50 +51 @@
-@@ -89,23 +89,22 @@ test_argparse_callback(uint32_t index, const char *value, void *opaque)
+@@ -86,23 +86,22 @@ test_argparse_callback(uint32_t index, const char *value, void *opaque)



More information about the stable mailing list