Skip to contentSkip to conversation

net/sched: avoid unused-label warning

PATCH Applied Arnd Bergmann 3 participants 4 messages Mar 4, 2019 – Mar 6, 2019

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

PATCH 1/1 net/sched: avoid unused-label warning

The label is only used from inside the #ifdef and should be hidden the same way, to avoid this warning:

net/sched/act_tunnel_key.c: In function 'tunnel_key_init':
net/sched/act_tunnel_key.c:389:1: error: label 'release_tun_meta' defined but not used [-Werror=unused-label]
release_tun_meta:

Fixes 41411e2fd6b8 ("net/sched: act_tunnel_key: Add dst_cache support")
---
 net/sched/act_tunnel_key.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/act_tunnel_key.c +1 -1
index 2a5f215ae876..3beb4717d3b7 100644
@@ -392,8 +392,8 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,
 #ifdef CONFIG_DST_CACHE
 	if (metadata)
 		dst_cache_destroy(&metadata->u.tun_info.dst_cache);
-#endif
 release_tun_meta:
+#endif
 	if (metadata)
 		dst_release(&metadata->dst);
 
Signature · 1 line
2.20.0
maintainer Applied
#1 lore raw

From: Arnd Bergmann <[email protected]>
Date: Mon, 4 Mar 2019 21:40:32 +0100

Quoted 9 lines

The label is only used from inside the #ifdef and should be hidden the same way, to avoid this warning:

net/sched/act_tunnel_key.c: In function 'tunnel_key_init':
net/sched/act_tunnel_key.c:389:1: error: label 'release_tun_meta' defined but not used [-Werror=unused-label]
release_tun_meta:

Fixes 41411e2fd6b8 ("net/sched: act_tunnel_key: Add dst_cache support")

Applied.

#2 lore raw
In reply to Arnd Bergmann
Quoted 19 lines · Arnd Bergmann

The label is only used from inside the #ifdef and should be hidden the same way, to avoid this warning:

net/sched/act_tunnel_key.c: In function 'tunnel_key_init':
net/sched/act_tunnel_key.c:389:1: error: label 'release_tun_meta' defined but not used [-Werror=unused-label]
release_tun_meta:

Fixes 41411e2fd6b8 ("net/sched: act_tunnel_key: Add dst_cache support")
---
 net/sched/act_tunnel_key.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/act_tunnel_key.c +0 -0
index 2a5f215ae876..3beb4717d3b7 100644

net/sched/act_tunnel_key.c static int tunnel_key_init(struct net *net, struct nlattr *nla, · line 396

Quoted 6 lines
net/sched/act_tunnel_key.c +1 -1
@@ -392,8 +392,8 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,
 #ifdef CONFIG_DST_CACHE
        if (metadata)
                dst_cache_destroy(&metadata->u.tun_info.dst_cache);
-#endif
 release_tun_meta:
+#endif

These #ifdef's are ugly, either we should select DST_CACHE or provide a nop for these dst_cache_*() APIs when it is not enabled.

#3 lore raw
Quoted 16 lines · Cong Wang

net/sched/act_tunnel_key.c static int tunnel_key_init(struct net *net, struct nlattr *nla, · line 396

Quoted 11 lines · Arnd Bergmann
net/sched/act_tunnel_key.c +1 -1
index 2a5f215ae876..3beb4717d3b7 100644
@@ -392,8 +392,8 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,
 #ifdef CONFIG_DST_CACHE
        if (metadata)
                dst_cache_destroy(&metadata->u.tun_info.dst_cache);
-#endif
 release_tun_meta:
+#endif

These #ifdef's are ugly, either we should select DST_CACHE or provide a nop for these dst_cache_*() APIs when it is not enabled.

I agree that would be nicer, or alternatively convert the preprocessor conditionals to C conditionals like

net/sched/act_tunnel_key.c +0 -0
index 3beb4717d3b7..586343a5accc 100644
@@ -327,11 +327,11 @@ static int tunnel_key_init(struct net *net,

struct nlattr *nla,

                        goto err_out;
                }

-#ifdef CONFIG_DST_CACHE
- ret = dst_cache_init(&metadata->u.tun_info.dst_cache,
GFP_KERNEL);
- if (ret)
- goto release_tun_meta;
-#endif
+ if (IS_ENABLED(CONFIG_DST_CACHE)) {
+ ret =
dst_cache_init(&metadata->u.tun_info.dst_cache, GFP_KERNEL);
+ if (ret)
+ goto release_tun_meta;
+ }

if (opts_len) {
ret = tunnel_key_opts_set(tb[TCA_TUNNEL_KEY_ENC_OPTS],
@@ -389,11 +389,9 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,

        return ret;

release_dst_cache:
-#ifdef CONFIG_DST_CACHE

        if (metadata)
                dst_cache_destroy(&metadata->u.tun_info.dst_cache);
 release_tun_meta:
-#endif
        if (metadata)
                dst_release(&metadata->dst);

Usually, you'd want to do that consistently though, and change all the related checks at the same time, so I would keep that separate from the trivial bugfix.

Arnd