From patchwork Wed Oct 28 11:35:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Bulwahn X-Patchwork-Id: 11862701 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F0994921 for ; Wed, 28 Oct 2020 11:35:46 +0000 (UTC) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2CD76246C7 for ; Wed, 28 Oct 2020 11:35:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=lists.elisa.tech header.i=@lists.elisa.tech header.b="njXqTygR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2CD76246C7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=bounce+72012+126+4688437+8417402@lists.elisa.tech X-Received: by 127.0.0.2 with SMTP id leY1YY4689772xcwoJUv29JS; Wed, 28 Oct 2020 04:35:45 -0700 X-Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by mx.groups.io with SMTP id smtpd.web12.7457.1603884944601564240 for ; Wed, 28 Oct 2020 04:35:44 -0700 X-Received: by mail-wm1-f66.google.com with SMTP id w23so4220128wmi.4 for ; Wed, 28 Oct 2020 04:35:44 -0700 (PDT) X-Gm-Message-State: Ej7le6LpzUPfUuq31sf1MVevx4688437AA= X-Google-Smtp-Source: ABdhPJzWzEGUl4KjLGJ2WRgqfIWkz3spMlmRWhF49/keLE8mg7+Jda9ImH3eqzpeVCsqwUWpshUujw== X-Received: by 2002:a1c:f604:: with SMTP id w4mr7798630wmc.87.1603884943015; Wed, 28 Oct 2020 04:35:43 -0700 (PDT) X-Received: from felia.fritz.box ([2001:16b8:2d7a:200:a915:6596:e9b0:4f60]) by smtp.gmail.com with ESMTPSA id s11sm6579979wrm.56.2020.10.28.04.35.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 04:35:42 -0700 (PDT) From: "Lukas Bulwahn" To: Jamal Hadi Salim , Cong Wang , Jiri Pirko , "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org Cc: Nathan Chancellor , Nick Desaulniers , Tom Rix , clang-built-linux@googlegroups.com, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-safety@lists.elisa.tech, Lukas Bulwahn Subject: [linux-safety] [PATCH] net: cls_api: remove unneeded local variable in tc_dump_chain() Date: Wed, 28 Oct 2020 12:35:33 +0100 Message-Id: <20201028113533.26160-1-lukas.bulwahn@gmail.com> Precedence: Bulk List-Unsubscribe: Sender: linux-safety@lists.elisa.tech List-Id: Mailing-List: list linux-safety@lists.elisa.tech; contact linux-safety+owner@lists.elisa.tech Delivered-To: mailing list linux-safety@lists.elisa.tech List-Post: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.elisa.tech; q=dns/txt; s=20140610; t=1603884945; bh=WLUvRAf+Ac9FHhujN/iKjnvfuxAuFT6bRbwJQSJkA8I=; h=Cc:Date:From:Subject:To; b=njXqTygRdI6tJbSNEgLmEdXuepbn9o8Zv5IZ7ZoJxZTsLX4xM7nFxZ6ukwbP3oi+NPu 571nRQZP+RfYkKj5fG4H57keB43A4aEvdGbxiAkWh9rq7oFFJ5AiaXWHZzu6DUxgF0Alx W9THm2XQxNZ6/rmgVdt4bBaUDcRk6oP+e/Q= 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 32a4f5ecd738 ("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 --- applies cleanly on current master and next-20201028 Jamal, Cong, Jiri, please ack. David, Jakub, please pick this minor non-urgent clean-up patch. net/sched/cls_api.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index faeabff283a2..8ce830ca5f92 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -2940,7 +2940,6 @@ static int tc_dump_chain(struct sk_buff *skb, struct netlink_callback *cb) struct tcf_chain *chain; long index_start; long index; - u32 parent; int err; if (nlmsg_len(cb->nlh) < sizeof(*tcm)) @@ -2955,13 +2954,6 @@ static int tc_dump_chain(struct sk_buff *skb, struct netlink_callback *cb) block = tcf_block_refcnt_get(net, tcm->tcm_block_index); if (!block) goto out; - /* If we work with block index, q is NULL and parent value - * will never be used in the following code. The check - * in tcf_fill_node prevents it. However, compiler does not - * see that far, so set parent to zero to silence the warning - * about parent being uninitialized. - */ - parent = 0; } else { const struct Qdisc_class_ops *cops; struct net_device *dev; @@ -2971,13 +2963,11 @@ static int tc_dump_chain(struct sk_buff *skb, struct netlink_callback *cb) if (!dev) return skb->len; - parent = tcm->tcm_parent; - if (!parent) { + if (!tcm->tcm_parent) q = dev->qdisc; - parent = q->handle; - } else { + else q = qdisc_lookup(dev, TC_H_MAJ(tcm->tcm_parent)); - } + if (!q) goto out; cops = q->ops->cl_ops;