Skip to contentSkip to conversation

net_sched: fix unused variable warning in stmmac

PATCH Applied Arnd Bergmann 2 participants 2 messages Aug 22, 2018 – Aug 23, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net_sched: fix unused variable warning in stmmac

The new tcf_exts_for_each_action() macro doesn't reference its arguments when CONFIG_NET_CLS_ACT is disabled, which leads to a harmless warning in at least one driver:

drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c: In function 'tc_fill_actions':
drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c:64:6: error: unused variable 'i' [-Werror=unused-variable]

Adding a cast to void lets us avoid this kind of warning. To be on the safe side, do it for all three arguments, not just the one that caused the warning.

Fixes 244cd96adb5f ("net_sched: remove list_head from tc_action")
---
 include/net/pkt_cls.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/net/pkt_cls.h +1 -1
index c17d51865469..75a3f3fdb359 100644
@@ -303,7 +303,7 @@ static inline void tcf_exts_put_net(struct tcf_exts *exts)
 	for (i = 0; i < TCA_ACT_MAX_PRIO && ((a) = (exts)->actions[i]); i++)
 #else
 #define tcf_exts_for_each_action(i, a, exts) \
-	for (; 0; )
+	for (; 0; (void)(i), (void)(a), (void)(exts))
 #endif
 
 static inline void
Signature · 1 line
2.18.0
maintainer Applied
#1 lore raw

From: Arnd Bergmann <[email protected]>
Date: Wed, 22 Aug 2018 17:25:44 +0200

Quoted 7 lines

The new tcf_exts_for_each_action() macro doesn't reference its arguments when CONFIG_NET_CLS_ACT is disabled, which leads to a harmless warning in at least one driver:

drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c: In function 'tc_fill_actions':
drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c:64:6: error: unused variable 'i' [-Werror=unused-variable]

Quoted 6 lines

Adding a cast to void lets us avoid this kind of warning. To be on the safe side, do it for all three arguments, not just the one that caused the warning.

Fixes 244cd96adb5f ("net_sched: remove list_head from tc_action")

Applied, thanks Arnd.