Skip to content

Commit 0ad41b2

Browse files
bulwahnkuba-moo
authored andcommitted
net: cls_api: remove unneeded local variable in tc_dump_chain()
make clang-analyzer on x86_64 defconfig caught my attention with: net/sched/cls_api.c:2964:3: warning: Value stored to 'parent' is never read [clang-analyzer-deadcode.DeadStores] parent = 0; ^ net/sched/cls_api.c:2977:4: warning: Value stored to 'parent' is never read [clang-analyzer-deadcode.DeadStores] parent = q->handle; ^ Commit 32a4f5e ("net: sched: introduce chain object to uapi") introduced tc_dump_chain() and this initial implementation already contained these unneeded dead stores. Simplify the code to make clang-analyzer happy. As compilers will detect these unneeded assignments and optimize this anyway, the resulting binary is identical before and after this change. No functional change. No change in object code. Signed-off-by: Lukas Bulwahn <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 400490a commit 0ad41b2

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

net/sched/cls_api.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2940,7 +2940,6 @@ static int tc_dump_chain(struct sk_buff *skb, struct netlink_callback *cb)
29402940
struct tcf_chain *chain;
29412941
long index_start;
29422942
long index;
2943-
u32 parent;
29442943
int err;
29452944

29462945
if (nlmsg_len(cb->nlh) < sizeof(*tcm))
@@ -2955,13 +2954,6 @@ static int tc_dump_chain(struct sk_buff *skb, struct netlink_callback *cb)
29552954
block = tcf_block_refcnt_get(net, tcm->tcm_block_index);
29562955
if (!block)
29572956
goto out;
2958-
/* If we work with block index, q is NULL and parent value
2959-
* will never be used in the following code. The check
2960-
* in tcf_fill_node prevents it. However, compiler does not
2961-
* see that far, so set parent to zero to silence the warning
2962-
* about parent being uninitialized.
2963-
*/
2964-
parent = 0;
29652957
} else {
29662958
const struct Qdisc_class_ops *cops;
29672959
struct net_device *dev;
@@ -2971,13 +2963,11 @@ static int tc_dump_chain(struct sk_buff *skb, struct netlink_callback *cb)
29712963
if (!dev)
29722964
return skb->len;
29732965

2974-
parent = tcm->tcm_parent;
2975-
if (!parent) {
2966+
if (!tcm->tcm_parent)
29762967
q = dev->qdisc;
2977-
parent = q->handle;
2978-
} else {
2968+
else
29792969
q = qdisc_lookup(dev, TC_H_MAJ(tcm->tcm_parent));
2980-
}
2970+
29812971
if (!q)
29822972
goto out;
29832973
cops = q->ops->cl_ops;

0 commit comments

Comments
 (0)