[RFC PATCH v2 21/33] app/pdump: fix warning about shadowed variable
Bruce Richardson
bruce.richardson at intel.com
Fri Nov 7 16:50:17 CET 2025
The variable name "optarg" is a standard global variable in getopt, so
use of that name for function parameters causes shadowing warnings.
Rename the variable to avoid these issues.
Fixes: caa7028276b8 ("app/pdump: add tool for packet capturing")
Cc: stable at dpdk.org
Signed-off-by: Bruce Richardson <bruce.richardson at intel.com>
---
app/pdump/main.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/app/pdump/main.c b/app/pdump/main.c
index fa85859703..5be382f8ca 100644
--- a/app/pdump/main.c
+++ b/app/pdump/main.c
@@ -247,7 +247,7 @@ parse_uint_value(const char *key, const char *value, void *extra_args)
}
static int
-parse_pdump(const char *optarg)
+parse_pdump(const char *arg)
{
struct rte_kvargs *kvlist;
int ret = 0, cnt1, cnt2;
@@ -257,9 +257,9 @@ parse_pdump(const char *optarg)
pt = &pdump_t[num_tuples];
/* initial check for invalid arguments */
- kvlist = rte_kvargs_parse(optarg, valid_pdump_arguments);
+ kvlist = rte_kvargs_parse(arg, valid_pdump_arguments);
if (kvlist == NULL) {
- printf("--pdump=\"%s\": invalid argument passed\n", optarg);
+ printf("--pdump=\"%s\": invalid argument passed\n", arg);
return -1;
}
@@ -268,7 +268,7 @@ parse_pdump(const char *optarg)
cnt2 = rte_kvargs_count(kvlist, PDUMP_PCI_ARG);
if (!((cnt1 == 1 && cnt2 == 0) || (cnt1 == 0 && cnt2 == 1))) {
printf("--pdump=\"%s\": must have either port or "
- "device_id argument\n", optarg);
+ "device_id argument\n", arg);
ret = -1;
goto free_kvlist;
} else if (cnt1 == 1) {
@@ -290,7 +290,7 @@ parse_pdump(const char *optarg)
/* queue parsing and validation */
cnt1 = rte_kvargs_count(kvlist, PDUMP_QUEUE_ARG);
if (cnt1 != 1) {
- printf("--pdump=\"%s\": must have queue argument\n", optarg);
+ printf("--pdump=\"%s\": must have queue argument\n", arg);
ret = -1;
goto free_kvlist;
}
@@ -303,7 +303,7 @@ parse_pdump(const char *optarg)
cnt2 = rte_kvargs_count(kvlist, PDUMP_TX_DEV_ARG);
if (cnt1 == 0 && cnt2 == 0) {
printf("--pdump=\"%s\": must have either rx-dev or "
- "tx-dev argument\n", optarg);
+ "tx-dev argument\n", arg);
ret = -1;
goto free_kvlist;
} else if (cnt1 == 1 && cnt2 == 1) {
--
2.48.1
More information about the dev
mailing list