* [PATCH iproute2-next 00/10] fix shadowed variable warnings
@ 2026-11-30 18:47 Stephen Hemminger
2026-11-30 18:47 ` [PATCH iproute2-next 01/10] xfrm: rename shadowed SA direction local Stephen Hemminger
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: Stephen Hemminger @ 2026-11-30 18:47 UTC (permalink / raw)
To: netdev; +Cc: dsahern, Stephen Hemminger
Shadowed variables cause bugs. Fix the ones already in the tree, then
turn on -Wshadow so new ones don't get in.
Stephen Hemminger (10):
xfrm: rename shadowed SA direction local
ip address: rename the shadowed parameter of ipaddr_reset_filter()
lib: rename parameters that shadow globals
xfrm: rename local netlink handles that shadow the global rth
tc: rename and drop shadowing locals
ip: rename and drop shadowing locals
ifstat: rename shadowing local
bridge, devlink, rdma: rename shadowing locals
ss: fix shadowed variable warnings
Makefile: enable shadowed variable warnings
Makefile | 2 +-
bridge/mdb.c | 6 ++--
devlink/devlink.c | 16 ++++-----
include/color.h | 2 +-
include/json_print.h | 10 +++---
ip/ip_common.h | 2 +-
ip/ipaddress.c | 16 ++++-----
ip/ipnexthop.c | 1 -
ip/iproute.c | 4 +--
ip/ipxfrm.c | 8 ++---
ip/xfrm_policy.c | 81 ++++++++++++++++++++++----------------------
ip/xfrm_state.c | 69 +++++++++++++++++++------------------
lib/color.c | 4 +--
lib/json_print.c | 18 +++++-----
misc/ifstat.c | 4 +--
rdma/rdma.c | 20 +++++------
ss/inet.c | 11 +++---
ss/tcp.c | 6 ++--
tc/f_route.c | 1 -
tc/m_pedit.c | 2 --
tc/tc_monitor.c | 12 +++----
21 files changed, 144 insertions(+), 151 deletions(-)
--
2.53.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH iproute2-next 01/10] xfrm: rename shadowed SA direction local
2026-11-30 18:47 [PATCH iproute2-next 00/10] fix shadowed variable warnings Stephen Hemminger
@ 2026-11-30 18:47 ` Stephen Hemminger
2026-11-30 18:47 ` [PATCH iproute2-next 02/10] ip address: rename the shadowed parameter of ipaddr_reset_filter() Stephen Hemminger
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Stephen Hemminger @ 2026-11-30 18:47 UTC (permalink / raw)
To: netdev; +Cc: dsahern, Stephen Hemminger
xfrm_xfrma_print() takes a bool parameter named "dir" that selects
whether the direction is printed. The XFRMA_SA_DIR block declares a
__u8 local of the same name holding the attribute value, so the two
distinct meanings share one identifier and the local hides the
parameter for the rest of the block.
Rename the local to sa_dir. No change in output; the fallback that
prints an unrecognized direction keeps reporting the attribute value
rather than the print flag.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
ip/ipxfrm.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/ip/ipxfrm.c b/ip/ipxfrm.c
index 78d9e192..4a63dc16 100644
--- a/ip/ipxfrm.c
+++ b/ip/ipxfrm.c
@@ -908,15 +908,15 @@ void xfrm_xfrma_print(struct rtattr *tb[], __u16 family, FILE *fp,
fprintf(fp, "%s", _SL_);
}
if (tb[XFRMA_SA_DIR]) {
- __u8 dir = rta_getattr_u8(tb[XFRMA_SA_DIR]);
+ __u8 sa_dir = rta_getattr_u8(tb[XFRMA_SA_DIR]);
fprintf(fp, "\tdir ");
- if (dir == XFRM_SA_DIR_IN)
+ if (sa_dir == XFRM_SA_DIR_IN)
fprintf(fp, "in");
- else if (dir == XFRM_SA_DIR_OUT)
+ else if (sa_dir == XFRM_SA_DIR_OUT)
fprintf(fp, "out");
else
- fprintf(fp, "other (%d)", dir);
+ fprintf(fp, "other (%d)", sa_dir);
fprintf(fp, "%s", _SL_);
}
if (tb[XFRMA_SA_PCPU]) {
--
2.53.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH iproute2-next 02/10] ip address: rename the shadowed parameter of ipaddr_reset_filter()
2026-11-30 18:47 [PATCH iproute2-next 00/10] fix shadowed variable warnings Stephen Hemminger
2026-11-30 18:47 ` [PATCH iproute2-next 01/10] xfrm: rename shadowed SA direction local Stephen Hemminger
@ 2026-11-30 18:47 ` Stephen Hemminger
2026-11-30 18:47 ` [PATCH iproute2-next 03/10] lib: rename parameters that shadow globals Stephen Hemminger
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Stephen Hemminger @ 2026-11-30 18:47 UTC (permalink / raw)
To: netdev; +Cc: dsahern, Stephen Hemminger
The first parameter is named oneline, shadowing the global of the same
name declared in utils.h. Rename it to on.
No functional change; the body already assigned the parameter.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
ip/ip_common.h | 2 +-
ip/ipaddress.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/ip/ip_common.h b/ip/ip_common.h
index 3f55ea33..52b998cf 100644
--- a/ip/ip_common.h
+++ b/ip/ip_common.h
@@ -46,7 +46,7 @@ void iplink_types_usage(void);
void iproute_reset_filter(int ifindex);
void ipmroute_reset_filter(int ifindex);
-void ipaddr_reset_filter(int oneline, int ifindex);
+void ipaddr_reset_filter(int on, int ifindex);
void ipneigh_reset_filter(int ifindex);
void ipnetconf_reset_filter(int ifindex);
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index fb9c05ee..976fe83c 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -2447,10 +2447,10 @@ int ipaddr_list_link(int argc, char **argv)
return ipaddr_list_flush_or_save(argc, argv, IPADD_LIST);
}
-void ipaddr_reset_filter(int oneline, int ifindex)
+void ipaddr_reset_filter(int on, int ifindex)
{
memset(&filter, 0, sizeof(filter));
- filter.oneline = oneline;
+ filter.oneline = on;
filter.ifindex = ifindex;
filter.group = -1;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH iproute2-next 03/10] lib: rename parameters that shadow globals
2026-11-30 18:47 [PATCH iproute2-next 00/10] fix shadowed variable warnings Stephen Hemminger
2026-11-30 18:47 ` [PATCH iproute2-next 01/10] xfrm: rename shadowed SA direction local Stephen Hemminger
2026-11-30 18:47 ` [PATCH iproute2-next 02/10] ip address: rename the shadowed parameter of ipaddr_reset_filter() Stephen Hemminger
@ 2026-11-30 18:47 ` Stephen Hemminger
2026-11-30 18:47 ` [PATCH iproute2-next 04/10] xfrm: rename local netlink handles that shadow the global rth Stephen Hemminger
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Stephen Hemminger @ 2026-11-30 18:47 UTC (permalink / raw)
To: netdev; +Cc: dsahern, Stephen Hemminger
new_json_obj(), new_json_obj_plain(), __new_json_obj() and
check_enable_color() take an int parameter named json, which shadows
the global of the same name. print_color_rate() does the same with
use_iec.
Rename the parameters; no functional change.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
include/color.h | 2 +-
include/json_print.h | 10 +++++-----
lib/color.c | 4 ++--
lib/json_print.c | 18 +++++++++---------
4 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/include/color.h b/include/color.h
index b543c267..4d9fff1f 100644
--- a/include/color.h
+++ b/include/color.h
@@ -21,7 +21,7 @@ enum color_opt {
};
int default_color_opt(void);
-bool check_enable_color(int color, int json);
+bool check_enable_color(int color, int is_json);
bool matches_color(const char *arg, int *val);
int color_fprintf(FILE *fp, enum color_attr attr, const char *fmt, ...);
enum color_attr ifa_family_color(__u8 ifa_family);
diff --git a/include/json_print.h b/include/json_print.h
index 79d8d4ff..56e82743 100644
--- a/include/json_print.h
+++ b/include/json_print.h
@@ -32,9 +32,9 @@ enum output_type {
PRINT_ANY = 4,
};
-void new_json_obj(int json);
+void new_json_obj(int is_json);
void delete_json_obj(void);
-void new_json_obj_plain(int json);
+void new_json_obj_plain(int is_json);
void delete_json_obj_plain(void);
bool is_json_context(void);
@@ -94,14 +94,14 @@ _PRINT_NAME_VALUE_FUNC(uint, unsigned int, u);
_PRINT_NAME_VALUE_FUNC(string, const char*, s);
#undef _PRINT_NAME_VALUE_FUNC
-int print_color_rate(bool use_iec, enum output_type t, enum color_attr color,
+int print_color_rate(bool iec, enum output_type t, enum color_attr color,
const char *key, const char *fmt, unsigned long long rate);
-static inline int print_rate(bool use_iec, enum output_type t,
+static inline int print_rate(bool iec, enum output_type t,
const char *key, const char *fmt,
unsigned long long rate)
{
- return print_color_rate(use_iec, t, COLOR_NONE, key, fmt, rate);
+ return print_color_rate(iec, t, COLOR_NONE, key, fmt, rate);
}
unsigned int print_range(const char *name, __u32 start, __u32 end);
diff --git a/lib/color.c b/lib/color.c
index aa112352..ddfda58a 100644
--- a/lib/color.c
+++ b/lib/color.c
@@ -97,9 +97,9 @@ int default_color_opt(void)
return CONF_COLOR;
}
-bool check_enable_color(int color, int json)
+bool check_enable_color(int color, int is_json)
{
- if (json || color == COLOR_OPT_NEVER)
+ if (is_json || color == COLOR_OPT_NEVER)
return false;
if (color == COLOR_OPT_ALWAYS || isatty(fileno(stdout))) {
diff --git a/lib/json_print.c b/lib/json_print.c
index e028e766..864e250b 100644
--- a/lib/json_print.c
+++ b/lib/json_print.c
@@ -13,9 +13,9 @@
static json_writer_t *_jw;
-static void __new_json_obj(int json, bool have_array)
+static void __new_json_obj(int is_json, bool have_array)
{
- if (json) {
+ if (is_json) {
_jw = jsonw_new(stdout);
if (!_jw) {
perror("json object");
@@ -37,9 +37,9 @@ static void __delete_json_obj(bool have_array)
}
}
-void new_json_obj(int json)
+void new_json_obj(int is_json)
{
- __new_json_obj(json, true);
+ __new_json_obj(is_json, true);
}
void delete_json_obj(void)
@@ -47,9 +47,9 @@ void delete_json_obj(void)
__delete_json_obj(true);
}
-void new_json_obj_plain(int json)
+void new_json_obj_plain(int is_json)
{
- __new_json_obj(json, false);
+ __new_json_obj(is_json, false);
}
void delete_json_obj_plain(void)
@@ -352,11 +352,11 @@ void print_nl(void)
printf("%s", _SL_);
}
-int print_color_rate(bool use_iec, enum output_type type, enum color_attr color,
+int print_color_rate(bool iec, enum output_type type, enum color_attr color,
const char *key, const char *fmt, unsigned long long rate)
{
- unsigned long kilo = use_iec ? 1024 : 1000;
- const char *str = use_iec ? "i" : "";
+ unsigned long kilo = iec ? 1024 : 1000;
+ const char *str = iec ? "i" : "";
static char *units[5] = {"", "K", "M", "G", "T"};
char *buf;
int rc;
--
2.53.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH iproute2-next 04/10] xfrm: rename local netlink handles that shadow the global rth
2026-11-30 18:47 [PATCH iproute2-next 00/10] fix shadowed variable warnings Stephen Hemminger
` (2 preceding siblings ...)
2026-11-30 18:47 ` [PATCH iproute2-next 03/10] lib: rename parameters that shadow globals Stephen Hemminger
@ 2026-11-30 18:47 ` Stephen Hemminger
2026-11-30 18:47 ` [PATCH iproute2-next 05/10] tc: rename and drop shadowing locals Stephen Hemminger
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Stephen Hemminger @ 2026-11-30 18:47 UTC (permalink / raw)
To: netdev; +Cc: dsahern, Stephen Hemminger
The xfrm commands open their own NETLINK_XFRM handle in a local named
rth, shadowing the global rth declared in ip_common.h. Rename the
locals to xrth.
xfrm_state_keep() and xfrm_policy_keep() aliased xb->rth into a local
rth used once; drop the alias and dereference xb->rth directly.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
ip/xfrm_policy.c | 81 ++++++++++++++++++++++++------------------------
ip/xfrm_state.c | 69 ++++++++++++++++++++---------------------
2 files changed, 74 insertions(+), 76 deletions(-)
diff --git a/ip/xfrm_policy.c b/ip/xfrm_policy.c
index 5261a292..ea7e8c0c 100644
--- a/ip/xfrm_policy.c
+++ b/ip/xfrm_policy.c
@@ -227,7 +227,7 @@ int xfrm_sctx_parse(char *ctxstr, char *s,
static int xfrm_policy_modify(int cmd, unsigned int flags, int argc, char **argv)
{
- struct rtnl_handle rth;
+ struct rtnl_handle xrth;
struct {
struct nlmsghdr n;
struct xfrm_userpolicy_info xpinfo;
@@ -399,16 +399,16 @@ static int xfrm_policy_modify(int cmd, unsigned int flags, int argc, char **argv
sizeof(xuo));
}
- if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0)
+ if (rtnl_open_byproto(&xrth, 0, NETLINK_XFRM) < 0)
exit(1);
if (req.xpinfo.sel.family == AF_UNSPEC)
req.xpinfo.sel.family = AF_INET;
- if (rtnl_talk(&rth, &req.n, NULL) < 0)
+ if (rtnl_talk(&xrth, &req.n, NULL) < 0)
exit(2);
- rtnl_close(&rth);
+ rtnl_close(&xrth);
return 0;
}
@@ -574,7 +574,7 @@ int xfrm_policy_print(struct nlmsghdr *n, void *arg)
static int xfrm_policy_get_or_delete(int argc, char **argv, int delete,
struct nlmsghdr **answer)
{
- struct rtnl_handle rth;
+ struct rtnl_handle xrth;
struct {
struct nlmsghdr n;
struct xfrm_userpolicy_id xpid;
@@ -669,7 +669,7 @@ static int xfrm_policy_get_or_delete(int argc, char **argv, int delete,
if (selp && indexp)
duparg2("SELECTOR", "INDEX");
- if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0)
+ if (rtnl_open_byproto(&xrth, 0, NETLINK_XFRM) < 0)
exit(1);
if (req.xpid.sel.family == AF_UNSPEC)
@@ -692,10 +692,10 @@ static int xfrm_policy_get_or_delete(int argc, char **argv, int delete,
if (is_if_id_set)
addattr32(&req.n, sizeof(req.buf), XFRMA_IF_ID, if_id);
- if (rtnl_talk(&rth, &req.n, answer) < 0)
+ if (rtnl_talk(&xrth, &req.n, answer) < 0)
exit(2);
- rtnl_close(&rth);
+ rtnl_close(&xrth);
return 0;
}
@@ -727,7 +727,6 @@ static int xfrm_policy_get(int argc, char **argv)
static int xfrm_policy_keep(struct nlmsghdr *n, void *arg)
{
struct xfrm_buffer *xb = (struct xfrm_buffer *)arg;
- struct rtnl_handle *rth = xb->rth;
struct xfrm_userpolicy_info *xpinfo = NLMSG_DATA(n);
int len = n->nlmsg_len;
struct rtattr *tb[XFRMA_MAX+1];
@@ -774,7 +773,7 @@ static int xfrm_policy_keep(struct nlmsghdr *n, void *arg)
new_n->nlmsg_len = NLMSG_LENGTH(sizeof(*xpid));
new_n->nlmsg_flags = NLM_F_REQUEST;
new_n->nlmsg_type = XFRM_MSG_DELPOLICY;
- new_n->nlmsg_seq = ++rth->seq;
+ new_n->nlmsg_seq = ++xb->rth->seq;
xpid = NLMSG_DATA(new_n);
memcpy(&xpid->sel, &xpinfo->sel, sizeof(xpid->sel));
@@ -804,7 +803,7 @@ static int xfrm_policy_keep(struct nlmsghdr *n, void *arg)
static int xfrm_policy_list_or_deleteall(int argc, char **argv, int deleteall)
{
char *selp = NULL;
- struct rtnl_handle rth;
+ struct rtnl_handle xrth;
if (argc > 0 || preferred_family != AF_UNSPEC)
filter.use = 1;
@@ -872,7 +871,7 @@ static int xfrm_policy_list_or_deleteall(int argc, char **argv, int deleteall)
argc--; argv++;
}
- if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0)
+ if (rtnl_open_byproto(&xrth, 0, NETLINK_XFRM) < 0)
exit(1);
if (deleteall) {
@@ -882,7 +881,7 @@ static int xfrm_policy_list_or_deleteall(int argc, char **argv, int deleteall)
xb.buf = buf;
xb.size = sizeof(buf);
- xb.rth = &rth;
+ xb.rth = &xrth;
for (i = 0; ; i++) {
struct {
@@ -892,7 +891,7 @@ static int xfrm_policy_list_or_deleteall(int argc, char **argv, int deleteall)
.n.nlmsg_len = NLMSG_HDRLEN,
.n.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
.n.nlmsg_type = XFRM_MSG_GETPOLICY,
- .n.nlmsg_seq = rth.dump = ++rth.seq,
+ .n.nlmsg_seq = xrth.dump = ++xrth.seq,
};
xb.offset = 0;
@@ -901,12 +900,12 @@ static int xfrm_policy_list_or_deleteall(int argc, char **argv, int deleteall)
if (show_stats > 1)
fprintf(stderr, "Delete-all round = %d\n", i);
- if (rtnl_send(&rth, (void *)&req, req.n.nlmsg_len) < 0) {
+ if (rtnl_send(&xrth, (void *)&req, req.n.nlmsg_len) < 0) {
perror("Cannot send dump request");
exit(1);
}
- if (rtnl_dump_filter(&rth, xfrm_policy_keep, &xb) < 0) {
+ if (rtnl_dump_filter(&xrth, xfrm_policy_keep, &xb) < 0) {
fprintf(stderr, "Delete-all terminated\n");
exit(1);
}
@@ -916,7 +915,7 @@ static int xfrm_policy_list_or_deleteall(int argc, char **argv, int deleteall)
break;
}
- if (rtnl_send_check(&rth, xb.buf, xb.offset) < 0) {
+ if (rtnl_send_check(&xrth, xb.buf, xb.offset) < 0) {
perror("Failed to send delete-all request");
exit(1);
}
@@ -934,21 +933,21 @@ static int xfrm_policy_list_or_deleteall(int argc, char **argv, int deleteall)
.n.nlmsg_len = NLMSG_HDRLEN,
.n.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
.n.nlmsg_type = XFRM_MSG_GETPOLICY,
- .n.nlmsg_seq = rth.dump = ++rth.seq,
+ .n.nlmsg_seq = xrth.dump = ++xrth.seq,
};
- if (rtnl_send(&rth, (void *)&req, req.n.nlmsg_len) < 0) {
+ if (rtnl_send(&xrth, (void *)&req, req.n.nlmsg_len) < 0) {
perror("Cannot send dump request");
exit(1);
}
- if (rtnl_dump_filter(&rth, xfrm_policy_print, stdout) < 0) {
+ if (rtnl_dump_filter(&xrth, xfrm_policy_print, stdout) < 0) {
fprintf(stderr, "Dump terminated\n");
exit(1);
}
}
- rtnl_close(&rth);
+ rtnl_close(&xrth);
exit(0);
}
@@ -1045,7 +1044,7 @@ static int print_spdinfo(struct nlmsghdr *n, void *arg)
static int xfrm_spd_setinfo(int argc, char **argv)
{
- struct rtnl_handle rth;
+ struct rtnl_handle xrth;
struct {
struct nlmsghdr n;
__u32 flags;
@@ -1098,20 +1097,20 @@ static int xfrm_spd_setinfo(int argc, char **argv)
argc--; argv++;
}
- if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0)
+ if (rtnl_open_byproto(&xrth, 0, NETLINK_XFRM) < 0)
exit(1);
- if (rtnl_talk(&rth, &req.n, NULL) < 0)
+ if (rtnl_talk(&xrth, &req.n, NULL) < 0)
exit(2);
- rtnl_close(&rth);
+ rtnl_close(&xrth);
return 0;
}
static int xfrm_spd_getinfo(int argc, char **argv)
{
- struct rtnl_handle rth;
+ struct rtnl_handle xrth;
struct {
struct nlmsghdr n;
__u32 flags;
@@ -1123,16 +1122,16 @@ static int xfrm_spd_getinfo(int argc, char **argv)
};
struct nlmsghdr *answer;
- if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0)
+ if (rtnl_open_byproto(&xrth, 0, NETLINK_XFRM) < 0)
exit(1);
- if (rtnl_talk(&rth, &req.n, &answer) < 0)
+ if (rtnl_talk(&xrth, &req.n, &answer) < 0)
exit(2);
print_spdinfo(answer, (void *)stdout);
free(answer);
- rtnl_close(&rth);
+ rtnl_close(&xrth);
return 0;
}
@@ -1167,7 +1166,7 @@ static char *xfrm_policy_to_str(uint8_t policy)
static int xfrm_spd_setdefault(int argc, char **argv)
{
- struct rtnl_handle rth;
+ struct rtnl_handle xrth;
struct {
struct nlmsghdr n;
struct xfrm_userpolicy_default up;
@@ -1206,13 +1205,13 @@ static int xfrm_spd_setdefault(int argc, char **argv)
argc--; argv++;
}
- if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0)
+ if (rtnl_open_byproto(&xrth, 0, NETLINK_XFRM) < 0)
exit(1);
- if (rtnl_talk(&rth, &req.n, NULL) < 0)
+ if (rtnl_talk(&xrth, &req.n, NULL) < 0)
exit(2);
- rtnl_close(&rth);
+ rtnl_close(&xrth);
return 0;
}
@@ -1239,7 +1238,7 @@ int xfrm_policy_default_print(struct nlmsghdr *n, FILE *fp)
static int xfrm_spd_getdefault(int argc, char **argv)
{
- struct rtnl_handle rth;
+ struct rtnl_handle xrth;
struct {
struct nlmsghdr n;
struct xfrm_userpolicy_default up;
@@ -1250,23 +1249,23 @@ static int xfrm_spd_getdefault(int argc, char **argv)
};
struct nlmsghdr *answer;
- if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0)
+ if (rtnl_open_byproto(&xrth, 0, NETLINK_XFRM) < 0)
exit(1);
- if (rtnl_talk(&rth, &req.n, &answer) < 0)
+ if (rtnl_talk(&xrth, &req.n, &answer) < 0)
exit(2);
xfrm_policy_default_print(answer, (FILE *)stdout);
free(answer);
- rtnl_close(&rth);
+ rtnl_close(&xrth);
return 0;
}
static int xfrm_policy_flush(int argc, char **argv)
{
- struct rtnl_handle rth;
+ struct rtnl_handle xrth;
struct {
struct nlmsghdr n;
char buf[RTA_BUF_SIZE];
@@ -1297,16 +1296,16 @@ static int xfrm_policy_flush(int argc, char **argv)
(void *)&upt, sizeof(upt));
}
- if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0)
+ if (rtnl_open_byproto(&xrth, 0, NETLINK_XFRM) < 0)
exit(1);
if (show_stats > 1)
fprintf(stderr, "Flush policy\n");
- if (rtnl_talk(&rth, &req.n, NULL) < 0)
+ if (rtnl_talk(&xrth, &req.n, NULL) < 0)
exit(2);
- rtnl_close(&rth);
+ rtnl_close(&xrth);
return 0;
}
diff --git a/ip/xfrm_state.c b/ip/xfrm_state.c
index dcd08d59..db80a0e0 100644
--- a/ip/xfrm_state.c
+++ b/ip/xfrm_state.c
@@ -269,7 +269,7 @@ static void xfrm_dir_parse(__u8 *dir, int *argcp, char ***argvp)
static int xfrm_state_modify(int cmd, unsigned int flags, int argc, char **argv)
{
- struct rtnl_handle rth;
+ struct rtnl_handle xrth;
struct {
struct nlmsghdr n;
struct xfrm_usersa_info xsinfo;
@@ -761,7 +761,7 @@ static int xfrm_state_modify(int cmd, unsigned int flags, int argc, char **argv)
if (output_mark.m)
addattr32(&req.n, sizeof(req.buf), XFRMA_SET_MARK_MASK, output_mark.m);
- if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0)
+ if (rtnl_open_byproto(&xrth, 0, NETLINK_XFRM) < 0)
exit(1);
if (dir) {
@@ -778,17 +778,17 @@ static int xfrm_state_modify(int cmd, unsigned int flags, int argc, char **argv)
if (req.xsinfo.family == AF_UNSPEC)
req.xsinfo.family = AF_INET;
- if (rtnl_talk(&rth, &req.n, NULL) < 0)
+ if (rtnl_talk(&xrth, &req.n, NULL) < 0)
exit(2);
- rtnl_close(&rth);
+ rtnl_close(&xrth);
return 0;
}
static int xfrm_state_allocspi(int argc, char **argv)
{
- struct rtnl_handle rth;
+ struct rtnl_handle xrth;
struct {
struct nlmsghdr n;
struct xfrm_userspi_info xspi;
@@ -917,14 +917,14 @@ static int xfrm_state_allocspi(int argc, char **argv)
if (pcpu_num != -1)
addattr32(&req.n, sizeof(req.buf), XFRMA_SA_PCPU, pcpu_num);
- if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0)
+ if (rtnl_open_byproto(&xrth, 0, NETLINK_XFRM) < 0)
exit(1);
if (req.xspi.info.family == AF_UNSPEC)
req.xspi.info.family = AF_INET;
- if (rtnl_talk(&rth, &req.n, &answer) < 0)
+ if (rtnl_talk(&xrth, &req.n, &answer) < 0)
exit(2);
if (xfrm_state_print(answer, (void *)stdout) < 0) {
@@ -933,7 +933,7 @@ static int xfrm_state_allocspi(int argc, char **argv)
}
free(answer);
- rtnl_close(&rth);
+ rtnl_close(&xrth);
return 0;
}
@@ -1067,7 +1067,7 @@ static int xfrm_state_print_nokeys(struct nlmsghdr *n, void *arg)
static int xfrm_state_get_or_delete(int argc, char **argv, int delete)
{
- struct rtnl_handle rth;
+ struct rtnl_handle xrth;
struct {
struct nlmsghdr n;
struct xfrm_usersa_id xsid;
@@ -1118,19 +1118,19 @@ static int xfrm_state_get_or_delete(int argc, char **argv, int delete)
}
}
- if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0)
+ if (rtnl_open_byproto(&xrth, 0, NETLINK_XFRM) < 0)
exit(1);
if (req.xsid.family == AF_UNSPEC)
req.xsid.family = AF_INET;
if (delete) {
- if (rtnl_talk(&rth, &req.n, NULL) < 0)
+ if (rtnl_talk(&xrth, &req.n, NULL) < 0)
exit(2);
} else {
struct nlmsghdr *answer;
- if (rtnl_talk(&rth, &req.n, &answer) < 0)
+ if (rtnl_talk(&xrth, &req.n, &answer) < 0)
exit(2);
if (xfrm_state_print(answer, (void *)stdout) < 0) {
@@ -1141,7 +1141,7 @@ static int xfrm_state_get_or_delete(int argc, char **argv, int delete)
free(answer);
}
- rtnl_close(&rth);
+ rtnl_close(&xrth);
return 0;
}
@@ -1153,7 +1153,6 @@ static int xfrm_state_get_or_delete(int argc, char **argv, int delete)
static int xfrm_state_keep(struct nlmsghdr *n, void *arg)
{
struct xfrm_buffer *xb = (struct xfrm_buffer *)arg;
- struct rtnl_handle *rth = xb->rth;
struct xfrm_usersa_info *xsinfo = NLMSG_DATA(n);
int len = n->nlmsg_len;
struct nlmsghdr *new_n;
@@ -1188,7 +1187,7 @@ static int xfrm_state_keep(struct nlmsghdr *n, void *arg)
new_n->nlmsg_len = NLMSG_LENGTH(sizeof(*xsid));
new_n->nlmsg_flags = NLM_F_REQUEST;
new_n->nlmsg_type = XFRM_MSG_DELSA;
- new_n->nlmsg_seq = ++rth->seq;
+ new_n->nlmsg_seq = ++xb->rth->seq;
xsid = NLMSG_DATA(new_n);
xsid->family = xsinfo->family;
@@ -1219,7 +1218,7 @@ static int xfrm_state_keep(struct nlmsghdr *n, void *arg)
static int xfrm_state_list_or_deleteall(int argc, char **argv, int deleteall)
{
char *idp = NULL;
- struct rtnl_handle rth;
+ struct rtnl_handle xrth;
bool nokeys = false;
if (argc > 0 || preferred_family != AF_UNSPEC)
@@ -1261,7 +1260,7 @@ static int xfrm_state_list_or_deleteall(int argc, char **argv, int deleteall)
argc--; argv++;
}
- if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0)
+ if (rtnl_open_byproto(&xrth, 0, NETLINK_XFRM) < 0)
exit(1);
if (deleteall) {
@@ -1271,7 +1270,7 @@ static int xfrm_state_list_or_deleteall(int argc, char **argv, int deleteall)
xb.buf = buf;
xb.size = sizeof(buf);
- xb.rth = &rth;
+ xb.rth = &xrth;
for (i = 0; ; i++) {
struct {
@@ -1281,7 +1280,7 @@ static int xfrm_state_list_or_deleteall(int argc, char **argv, int deleteall)
.n.nlmsg_len = NLMSG_HDRLEN,
.n.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
.n.nlmsg_type = XFRM_MSG_GETSA,
- .n.nlmsg_seq = rth.dump = ++rth.seq,
+ .n.nlmsg_seq = xrth.dump = ++xrth.seq,
};
xb.offset = 0;
@@ -1290,12 +1289,12 @@ static int xfrm_state_list_or_deleteall(int argc, char **argv, int deleteall)
if (show_stats > 1)
fprintf(stderr, "Delete-all round = %d\n", i);
- if (rtnl_send(&rth, (void *)&req, req.n.nlmsg_len) < 0) {
+ if (rtnl_send(&xrth, (void *)&req, req.n.nlmsg_len) < 0) {
perror("Cannot send dump request");
exit(1);
}
- if (rtnl_dump_filter(&rth, xfrm_state_keep, &xb) < 0) {
+ if (rtnl_dump_filter(&xrth, xfrm_state_keep, &xb) < 0) {
fprintf(stderr, "Delete-all terminated\n");
exit(1);
}
@@ -1305,7 +1304,7 @@ static int xfrm_state_list_or_deleteall(int argc, char **argv, int deleteall)
break;
}
- if (rtnl_send_check(&rth, xb.buf, xb.offset) < 0) {
+ if (rtnl_send_check(&xrth, xb.buf, xb.offset) < 0) {
perror("Failed to send delete-all request\n");
exit(1);
}
@@ -1331,7 +1330,7 @@ static int xfrm_state_list_or_deleteall(int argc, char **argv, int deleteall)
.n.nlmsg_len = NLMSG_HDRLEN,
.n.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
.n.nlmsg_type = XFRM_MSG_GETSA,
- .n.nlmsg_seq = rth.dump = ++rth.seq,
+ .n.nlmsg_seq = xrth.dump = ++xrth.seq,
};
if (filter.xsinfo.id.proto)
@@ -1340,20 +1339,20 @@ static int xfrm_state_list_or_deleteall(int argc, char **argv, int deleteall)
addattr_l(&req.n, sizeof(req), XFRMA_ADDRESS_FILTER,
&addrfilter, sizeof(addrfilter));
- if (rtnl_send(&rth, (void *)&req, req.n.nlmsg_len) < 0) {
+ if (rtnl_send(&xrth, (void *)&req, req.n.nlmsg_len) < 0) {
perror("Cannot send dump request");
exit(1);
}
- rtnl_filter_t filter = nokeys ?
+ rtnl_filter_t dump_filter = nokeys ?
xfrm_state_print_nokeys : xfrm_state_print;
- if (rtnl_dump_filter(&rth, filter, stdout) < 0) {
+ if (rtnl_dump_filter(&xrth, dump_filter, stdout) < 0) {
fprintf(stderr, "Dump terminated\n");
exit(1);
}
}
- rtnl_close(&rth);
+ rtnl_close(&xrth);
exit(0);
}
@@ -1409,7 +1408,7 @@ static int print_sadinfo(struct nlmsghdr *n, void *arg)
static int xfrm_sad_getinfo(int argc, char **argv)
{
- struct rtnl_handle rth;
+ struct rtnl_handle xrth;
struct {
struct nlmsghdr n;
__u32 flags;
@@ -1421,23 +1420,23 @@ static int xfrm_sad_getinfo(int argc, char **argv)
};
struct nlmsghdr *answer;
- if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0)
+ if (rtnl_open_byproto(&xrth, 0, NETLINK_XFRM) < 0)
exit(1);
- if (rtnl_talk(&rth, &req.n, &answer) < 0)
+ if (rtnl_talk(&xrth, &req.n, &answer) < 0)
exit(2);
print_sadinfo(answer, (void *)stdout);
free(answer);
- rtnl_close(&rth);
+ rtnl_close(&xrth);
return 0;
}
static int xfrm_state_flush(int argc, char **argv)
{
- struct rtnl_handle rth;
+ struct rtnl_handle xrth;
struct {
struct nlmsghdr n;
struct xfrm_usersa_flush xsf;
@@ -1469,17 +1468,17 @@ static int xfrm_state_flush(int argc, char **argv)
argc--; argv++;
}
- if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0)
+ if (rtnl_open_byproto(&xrth, 0, NETLINK_XFRM) < 0)
exit(1);
if (show_stats > 1)
fprintf(stderr, "Flush state with XFRM-PROTO value \"%s\"\n",
strxf_xfrmproto(req.xsf.proto));
- if (rtnl_talk(&rth, &req.n, NULL) < 0)
+ if (rtnl_talk(&xrth, &req.n, NULL) < 0)
exit(2);
- rtnl_close(&rth);
+ rtnl_close(&xrth);
return 0;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH iproute2-next 05/10] tc: rename and drop shadowing locals
2026-11-30 18:47 [PATCH iproute2-next 00/10] fix shadowed variable warnings Stephen Hemminger
` (3 preceding siblings ...)
2026-11-30 18:47 ` [PATCH iproute2-next 04/10] xfrm: rename local netlink handles that shadow the global rth Stephen Hemminger
@ 2026-11-30 18:47 ` Stephen Hemminger
2026-11-30 18:47 ` [PATCH iproute2-next 06/10] ip: " Stephen Hemminger
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Stephen Hemminger @ 2026-11-30 18:47 UTC (permalink / raw)
To: netdev; +Cc: dsahern, Stephen Hemminger, Jamal Hadi Salim
do_tcmonitor() opens its own handle in a local named rth, shadowing the
global declared in tc_common.h; rename it to mrth.
route_print_opt() invokes SPRINT_BUF(b1) twice in the same function and
print_pedit() redeclares int err while the enclosing one is not yet
live; drop the inner declarations.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
tc/f_route.c | 1 -
tc/m_pedit.c | 2 --
tc/tc_monitor.c | 12 ++++++------
3 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/tc/f_route.c b/tc/f_route.c
index c234ddf0..be313784 100644
--- a/tc/f_route.c
+++ b/tc/f_route.c
@@ -150,7 +150,6 @@ static int route_print_opt(const struct filter_util *qu, FILE *f, struct rtattr
print_uint(PRINT_ANY, "order", "order %d ", (handle >> 8) & 0x7F);
if (tb[TCA_ROUTE4_CLASSID]) {
- SPRINT_BUF(b1);
print_string(PRINT_ANY, "flowid", "flowid %s ",
sprint_tc_classid(rta_getattr_u32(tb[TCA_ROUTE4_CLASSID]), b1));
}
diff --git a/tc/m_pedit.c b/tc/m_pedit.c
index 040d6168..07360c04 100644
--- a/tc/m_pedit.c
+++ b/tc/m_pedit.c
@@ -766,8 +766,6 @@ static int print_pedit(const struct action_util *au, FILE *f, struct rtattr *arg
if (tb[TCA_PEDIT_PARMS]) {
sel = RTA_DATA(tb[TCA_PEDIT_PARMS]);
} else {
- int err;
-
sel = RTA_DATA(tb[TCA_PEDIT_PARMS_EX]);
if (!tb[TCA_PEDIT_KEYS_EX]) {
diff --git a/tc/tc_monitor.c b/tc/tc_monitor.c
index 5b9bccbe..fdbe6e4e 100644
--- a/tc/tc_monitor.c
+++ b/tc/tc_monitor.c
@@ -67,7 +67,7 @@ static int accept_tcmsg(struct rtnl_ctrl_data *ctrl,
int do_tcmonitor(int argc, char **argv)
{
- struct rtnl_handle rth;
+ struct rtnl_handle mrth;
char *file = NULL;
unsigned int groups = nl_mgrp(RTNLGRP_TC);
@@ -100,16 +100,16 @@ int do_tcmonitor(int argc, char **argv)
return ret;
}
- if (rtnl_open(&rth, groups) < 0)
+ if (rtnl_open(&mrth, groups) < 0)
exit(1);
- ll_init_map(&rth);
+ ll_init_map(&mrth);
- if (rtnl_listen(&rth, accept_tcmsg, (void *)stdout) < 0) {
- rtnl_close(&rth);
+ if (rtnl_listen(&mrth, accept_tcmsg, (void *)stdout) < 0) {
+ rtnl_close(&mrth);
exit(2);
}
- rtnl_close(&rth);
+ rtnl_close(&mrth);
exit(0);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH iproute2-next 06/10] ip: rename and drop shadowing locals
2026-11-30 18:47 [PATCH iproute2-next 00/10] fix shadowed variable warnings Stephen Hemminger
` (4 preceding siblings ...)
2026-11-30 18:47 ` [PATCH iproute2-next 05/10] tc: rename and drop shadowing locals Stephen Hemminger
@ 2026-11-30 18:47 ` Stephen Hemminger
2026-11-30 18:47 ` [PATCH iproute2-next 07/10] ifstat: rename shadowing local Stephen Hemminger
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Stephen Hemminger @ 2026-11-30 18:47 UTC (permalink / raw)
To: netdev; +Cc: dsahern, Stephen Hemminger
print_linkinfo() declares char *name inside the LINK_NETNSID and
NEW_NETNSID blocks, shadowing the interface name in the enclosing
scope; rename them to nsname.
filter_nlmsg() declares struct rtvia *via, shadowing the inet_prefix
via used for the gateway filter match; rename it to rtvia, matching
the local used for the same attribute a few lines below.
ipnh_modify() redeclares int ret inside the hw_stats branch while the
enclosing ret is not yet live; drop the inner declaration.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
ip/ipaddress.c | 12 ++++++------
ip/ipnexthop.c | 1 -
ip/iproute.c | 4 ++--
3 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 976fe83c..94e98102 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -1118,11 +1118,11 @@ int print_linkinfo(struct nlmsghdr *n, void *arg)
print_int(PRINT_JSON, "link_netnsid", NULL, id);
} else {
if (id >= 0) {
- char *name = get_name_from_nsid(id);
+ char *nsname = get_name_from_nsid(id);
- if (name)
+ if (nsname)
print_string(PRINT_FP, NULL,
- " link-netns %s", name);
+ " link-netns %s", nsname);
else
print_int(PRINT_FP, NULL,
" link-netnsid %d", id);
@@ -1134,10 +1134,10 @@ int print_linkinfo(struct nlmsghdr *n, void *arg)
if (tb[IFLA_NEW_NETNSID]) {
int id = rta_getattr_u32(tb[IFLA_NEW_NETNSID]);
- char *name = get_name_from_nsid(id);
+ char *nsname = get_name_from_nsid(id);
- if (name)
- print_string(PRINT_FP, NULL, " new-netns %s", name);
+ if (nsname)
+ print_string(PRINT_FP, NULL, " new-netns %s", nsname);
else
print_int(PRINT_FP, NULL, " new-netnsid %d", id);
}
diff --git a/ip/ipnexthop.c b/ip/ipnexthop.c
index ae6a28d4..fd854f89 100644
--- a/ip/ipnexthop.c
+++ b/ip/ipnexthop.c
@@ -1144,7 +1144,6 @@ static int ipnh_modify(int cmd, unsigned int flags, int argc, char **argv)
req.nhm.nh_protocol = prot;
} else if (!strcmp(*argv, "hw_stats")) {
bool hw_stats;
- int ret;
NEXT_ARG();
hw_stats = parse_on_off("hw_stats", *argv, &ret);
diff --git a/ip/iproute.c b/ip/iproute.c
index 067569c2..ce7c9ef2 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -259,9 +259,9 @@ static int filter_nlmsg(struct nlmsghdr *n, struct rtattr **tb, int host_len)
int family = r->rtm_family;
if (tb[RTA_VIA]) {
- struct rtvia *via = RTA_DATA(tb[RTA_VIA]);
+ struct rtvia *rtvia = RTA_DATA(tb[RTA_VIA]);
- family = via->rtvia_family;
+ family = rtvia->rtvia_family;
}
if (family != filter.rvia.family)
return 0;
--
2.53.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH iproute2-next 07/10] ifstat: rename shadowing local
2026-11-30 18:47 [PATCH iproute2-next 00/10] fix shadowed variable warnings Stephen Hemminger
` (5 preceding siblings ...)
2026-11-30 18:47 ` [PATCH iproute2-next 06/10] ip: " Stephen Hemminger
@ 2026-11-30 18:47 ` Stephen Hemminger
2026-11-30 18:47 ` [PATCH iproute2-next 08/10] bridge, devlink, rdma: rename shadowing locals Stephen Hemminger
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Stephen Hemminger @ 2026-11-30 18:47 UTC (permalink / raw)
To: netdev; +Cc: dsahern, Stephen Hemminger
The IFLA_STATS branch declares __u32 *stats, shadowing the static
stats[] name table at file scope. Rename it to ival, matching the
field it is copied into.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
misc/ifstat.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/misc/ifstat.c b/misc/ifstat.c
index ec59a9eb..319fc332 100644
--- a/misc/ifstat.c
+++ b/misc/ifstat.c
@@ -206,11 +206,11 @@ static int get_nlmsg(struct nlmsghdr *m, void *arg)
if (tb[IFLA_STATS64]) {
memcpy(&n->ival, RTA_DATA(tb[IFLA_STATS64]), sizeof(n->ival));
} else if (tb[IFLA_STATS]) {
- __u32 *stats = RTA_DATA(tb[IFLA_STATS]);
+ __u32 *ival = RTA_DATA(tb[IFLA_STATS]);
/* expand 32 bit values to 64 bit */
for (i = 0; i < MAXS; i++)
- n->ival[i] = stats[i];
+ n->ival[i] = ival[i];
} else {
/* missing stats? */
free(n);
--
2.53.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH iproute2-next 08/10] bridge, devlink, rdma: rename shadowing locals
2026-11-30 18:47 [PATCH iproute2-next 00/10] fix shadowed variable warnings Stephen Hemminger
` (6 preceding siblings ...)
2026-11-30 18:47 ` [PATCH iproute2-next 07/10] ifstat: rename shadowing local Stephen Hemminger
@ 2026-11-30 18:47 ` Stephen Hemminger
2026-11-30 18:47 ` [PATCH iproute2-next 09/10] ss: fix shadowed variable warnings Stephen Hemminger
2026-11-30 18:47 ` [PATCH iproute2-next 10/10] Makefile: enable " Stephen Hemminger
9 siblings, 0 replies; 11+ messages in thread
From: Stephen Hemminger @ 2026-11-30 18:47 UTC (permalink / raw)
To: netdev
Cc: dsahern, Stephen Hemminger, Ido Schimmel, Nikolay Aleksandrov,
Jiri Pirko, Leon Romanovsky, bridge
print_mdb_entry() declares unsigned int ifindex for the entry's via
interface, shadowing the bridge port parameter of the same name.
devlink opens a local handle named rth and iterates version attributes
in a local named version, shadowing the global rth and the version[]
string from version.h.
rdma's main() keeps its option state in locals named show_details,
show_raw and oneline, shadowing the globals of the same names that it
never reads.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
bridge/mdb.c | 6 +++---
devlink/devlink.c | 16 ++++++++--------
rdma/rdma.c | 20 ++++++++++----------
3 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/bridge/mdb.c b/bridge/mdb.c
index 112deeb9..ccaf41da 100644
--- a/bridge/mdb.c
+++ b/bridge/mdb.c
@@ -279,11 +279,11 @@ static void print_mdb_entry(FILE *f, int ifindex, const struct br_mdb_entry *e,
rta_getattr_u32(tb[MDBA_MDB_EATTR_SRC_VNI]));
if (tb[MDBA_MDB_EATTR_IFINDEX]) {
- unsigned int ifindex;
+ unsigned int via_ifindex;
- ifindex = rta_getattr_u32(tb[MDBA_MDB_EATTR_IFINDEX]);
+ via_ifindex = rta_getattr_u32(tb[MDBA_MDB_EATTR_IFINDEX]);
print_string(PRINT_ANY, "via", " via %s",
- ll_index_to_name(ifindex));
+ ll_index_to_name(via_ifindex));
}
if (show_stats && tb && tb[MDBA_MDB_EATTR_TIMER]) {
diff --git a/devlink/devlink.c b/devlink/devlink.c
index b6b24b49..c839e92a 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -846,13 +846,13 @@ static int ifname_map_rtnl_init(struct dl *dl, const char *ifname)
.i.ifi_family = AF_UNSPEC,
};
struct rtattr *tb[IFLA_MAX + 1];
- struct rtnl_handle rth;
+ struct rtnl_handle drth;
struct ifinfomsg *ifi;
struct nlmsghdr *n = NULL;
int len;
int err;
- if (rtnl_open(&rth, 0) < 0) {
+ if (rtnl_open(&drth, 0) < 0) {
pr_err("Cannot open rtnetlink\n");
return -EINVAL;
}
@@ -861,7 +861,7 @@ static int ifname_map_rtnl_init(struct dl *dl, const char *ifname)
!check_ifname(ifname) ? IFLA_IFNAME : IFLA_ALT_IFNAME,
ifname, strlen(ifname) + 1);
- if (rtnl_talk(&rth, &req.n, &n) < 0) {
+ if (rtnl_talk(&drth, &req.n, &n) < 0) {
err = -EINVAL;
goto out;
}
@@ -890,7 +890,7 @@ static int ifname_map_rtnl_init(struct dl *dl, const char *ifname)
out:
free(n);
- rtnl_close(&rth);
+ rtnl_close(&drth);
return err;
}
@@ -4411,18 +4411,18 @@ static int cmd_dev_reload(struct dl *dl)
static void pr_out_versions_single(struct dl *dl, const struct nlmsghdr *nlh,
const char *name, int type)
{
- struct nlattr *version;
+ struct nlattr *ver_attr;
- mnl_attr_for_each(version, nlh, sizeof(struct genlmsghdr)) {
+ mnl_attr_for_each(ver_attr, nlh, sizeof(struct genlmsghdr)) {
struct nlattr *tb[DEVLINK_ATTR_MAX + 1] = {};
const char *ver_value;
const char *ver_name;
int err;
- if (mnl_attr_get_type(version) != type)
+ if (mnl_attr_get_type(ver_attr) != type)
continue;
- err = mnl_attr_parse_nested(version, attr_cb, tb);
+ err = mnl_attr_parse_nested(ver_attr, attr_cb, tb);
if (err != MNL_CB_OK)
continue;
diff --git a/rdma/rdma.c b/rdma/rdma.c
index 253ac58b..9d775478 100644
--- a/rdma/rdma.c
+++ b/rdma/rdma.c
@@ -100,10 +100,10 @@ int main(int argc, char **argv)
};
bool show_driver_details = false;
const char *batch_file = NULL;
- bool show_details = false;
- bool show_raw = false;
+ bool details = false;
+ bool raw = false;
bool force = false;
- bool oneline = false;
+ bool single_line = false;
struct rd rd = {};
char *filename;
int opt;
@@ -121,16 +121,16 @@ int main(int argc, char **argv)
++pretty;
break;
case 'd':
- if (show_details)
+ if (details)
show_driver_details = true;
else
- show_details = true;
+ details = true;
break;
case 'r':
- show_raw = true;
+ raw = true;
break;
case 'o':
- oneline = true;
+ single_line = true;
break;
case 'j':
++json;
@@ -157,11 +157,11 @@ int main(int argc, char **argv)
argc -= optind;
argv += optind;
- _SL_ = oneline ? "\\" : "\n";
+ _SL_ = single_line ? "\\" : "\n";
- rd.show_details = show_details;
+ rd.show_details = details;
rd.show_driver_details = show_driver_details;
- rd.show_raw = show_raw;
+ rd.show_raw = raw;
err = rd_init(&rd, filename);
if (err)
--
2.53.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH iproute2-next 09/10] ss: fix shadowed variable warnings
2026-11-30 18:47 [PATCH iproute2-next 00/10] fix shadowed variable warnings Stephen Hemminger
` (7 preceding siblings ...)
2026-11-30 18:47 ` [PATCH iproute2-next 08/10] bridge, devlink, rdma: rename shadowing locals Stephen Hemminger
@ 2026-11-30 18:47 ` Stephen Hemminger
2026-11-30 18:47 ` [PATCH iproute2-next 10/10] Makefile: enable " Stephen Hemminger
9 siblings, 0 replies; 11+ messages in thread
From: Stephen Hemminger @ 2026-11-30 18:47 UTC (permalink / raw)
To: netdev; +Cc: dsahern, Stephen Hemminger
Rename variables to avoid shadowing.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
ss/inet.c | 11 +++++------
ss/tcp.c | 6 +++---
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/ss/inet.c b/ss/inet.c
index 53720983..d916e23b 100644
--- a/ss/inet.c
+++ b/ss/inet.c
@@ -478,14 +478,13 @@ static int tcp_show_netlink_file(struct filter *f)
err = -1;
if (h->nlmsg_type == NLMSG_ERROR) {
- struct nlmsgerr *err = (struct nlmsgerr *)NLMSG_DATA(h);
+ const struct nlmsgerr *emsg = NLMSG_DATA(h);
- if (h->nlmsg_len < NLMSG_LENGTH(sizeof(struct nlmsgerr))) {
+ if (h->nlmsg_len < NLMSG_LENGTH(sizeof(struct nlmsgerr)))
fprintf(stderr, "ERROR truncated\n");
- } else {
- errno = -err->error;
- perror("TCPDIAG answered");
- }
+ else
+ fprintf(stderr, "TCPDIAG answered: %s\n",
+ strerror(-emsg->error));
break;
}
diff --git a/ss/tcp.c b/ss/tcp.c
index 36e8cb3a..5809f9fb 100644
--- a/ss/tcp.c
+++ b/ss/tcp.c
@@ -451,12 +451,12 @@ void tcp_show_info(const struct nlmsghdr *nlh, struct inet_diag_msg *r,
if (tb[INET_DIAG_BBRINFO]) {
const void *bbr_info = RTA_DATA(tb[INET_DIAG_BBRINFO]);
- int len = min(RTA_PAYLOAD(tb[INET_DIAG_BBRINFO]),
- sizeof(*s.bbr_info));
+ int bbr_len = min(RTA_PAYLOAD(tb[INET_DIAG_BBRINFO]),
+ sizeof(*s.bbr_info));
s.bbr_info = calloc(1, sizeof(*s.bbr_info));
if (s.bbr_info && bbr_info)
- memcpy(s.bbr_info, bbr_info, len);
+ memcpy(s.bbr_info, bbr_info, bbr_len);
}
if (rtt > 0 && info->tcpi_snd_mss && info->tcpi_snd_cwnd) {
--
2.53.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH iproute2-next 10/10] Makefile: enable shadowed variable warnings
2026-11-30 18:47 [PATCH iproute2-next 00/10] fix shadowed variable warnings Stephen Hemminger
` (8 preceding siblings ...)
2026-11-30 18:47 ` [PATCH iproute2-next 09/10] ss: fix shadowed variable warnings Stephen Hemminger
@ 2026-11-30 18:47 ` Stephen Hemminger
9 siblings, 0 replies; 11+ messages in thread
From: Stephen Hemminger @ 2026-11-30 18:47 UTC (permalink / raw)
To: netdev; +Cc: dsahern, Stephen Hemminger
Shadowed variables often lead to bugs and confusion so enable
that warning.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index d3755305..5a854295 100644
--- a/Makefile
+++ b/Makefile
@@ -49,7 +49,7 @@ DEFINES += -D_GNU_SOURCE
# Turn on transparent support for LFS
DEFINES += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
CCOPTS = -O2 -pipe
-WFLAGS := -Wall -Wstrict-prototypes -Wmissing-prototypes
+WFLAGS := -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow
WFLAGS += -Wmissing-declarations -Wold-style-definition -Wformat=2
CFLAGS := $(WFLAGS) $(CCOPTS) -I../include -I../include/uapi $(DEFINES) $(CFLAGS)
--
2.53.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-11-30 19:11 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 18:47 [PATCH iproute2-next 00/10] fix shadowed variable warnings Stephen Hemminger
2026-11-30 18:47 ` [PATCH iproute2-next 01/10] xfrm: rename shadowed SA direction local Stephen Hemminger
2026-11-30 18:47 ` [PATCH iproute2-next 02/10] ip address: rename the shadowed parameter of ipaddr_reset_filter() Stephen Hemminger
2026-11-30 18:47 ` [PATCH iproute2-next 03/10] lib: rename parameters that shadow globals Stephen Hemminger
2026-11-30 18:47 ` [PATCH iproute2-next 04/10] xfrm: rename local netlink handles that shadow the global rth Stephen Hemminger
2026-11-30 18:47 ` [PATCH iproute2-next 05/10] tc: rename and drop shadowing locals Stephen Hemminger
2026-11-30 18:47 ` [PATCH iproute2-next 06/10] ip: " Stephen Hemminger
2026-11-30 18:47 ` [PATCH iproute2-next 07/10] ifstat: rename shadowing local Stephen Hemminger
2026-11-30 18:47 ` [PATCH iproute2-next 08/10] bridge, devlink, rdma: rename shadowing locals Stephen Hemminger
2026-11-30 18:47 ` [PATCH iproute2-next 09/10] ss: fix shadowed variable warnings Stephen Hemminger
2026-11-30 18:47 ` [PATCH iproute2-next 10/10] Makefile: enable " Stephen Hemminger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox