[PATCH v4 09/31] pcapng: rename variable to fix shadowing

Bruce Richardson
2026-01-14T15:46:08Z

The "len" variable is shadowed within a function, so rename inner use to
the more descriptive "filter_len" to fix the issue.

Fixes: d1da6d0d04c7 ("pcapng: require per-interface information")
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/pcapng/rte_pcapng.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/lib/pcapng/rte_pcapng.c b/lib/pcapng/rte_pcapng.c
index 21bc94cea1..2cc9e2040d 100644
--- a/lib/pcapng/rte_pcapng.c
+++ b/lib/pcapng/rte_pcapng.c
@@ -296,16 +296,15 @@ rte_pcapng_add_interface(rte_pcapng_t *self, uint16_t port, uint16_t link_type,
opt = pcapng_add_option(opt, PCAPNG_IFB_HARDWARE,
ifhw, strlen(ifhw));
if (filter) {
- size_t len;
+ const size_t filter_len = strlen(filter) + 1;

- len = strlen(filter) + 1;
opt->code = PCAPNG_IFB_FILTER;
- opt->length = len;
+ opt->length = filter_len;
/* Encoding is that the first octet indicates string vs BPF */
opt->data[0] = 0;
memcpy(opt->data + 1, filter, strlen(filter));

- opt = (struct pcapng_option *)((uint8_t *)opt + pcapng_optlen(len));
+ opt = (struct pcapng_option *)((uint8_t *)opt + pcapng_optlen(filter_len));
}

opt = pcapng_add_option(opt, PCAPNG_OPT_END, NULL, 0);
--
2.51.0