mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Florian Westphal <fw@strlen.de>
Cc: kbuild-all@lists.01.org, linux-kernel@vger.kernel.org,
	Pablo Neira Ayuso <pablo@netfilter.org>
Subject: net/netfilter/nf_conntrack_core.c:1736:8: warning: Local variable 'tmp' shadows outer variable [shadowVariable]
Date: Wed, 4 May 2022 09:39:30 +0800	[thread overview]
Message-ID: <202205040943.Gd2qI52I-lkp@intel.com> (raw)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   107c948d1d3e61d10aee9d0f7c3d81bbee9842af
commit: b16ac3c4c886f323b06ae942f02ebd2a70bf8840 netfilter: conntrack: include zone id in tuple hash again
date:   8 months ago
compiler: powerpc64-linux-gcc (GCC) 11.3.0
reproduce (cppcheck warning):
        # apt-get install cppcheck
        git checkout b16ac3c4c886f323b06ae942f02ebd2a70bf8840
        cppcheck --quiet --enable=style,performance,portability --template=gcc FILE

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


cppcheck warnings: (new ones prefixed by >>)
>> net/netfilter/nf_conntrack_core.c:1736:8: warning: Local variable 'tmp' shadows outer variable [shadowVariable]
      u32 tmp = hash_conntrack_raw(&tuple, rid, state->net);
          ^
   net/netfilter/nf_conntrack_core.c:1715:27: note: Shadowed declaration
    struct nf_conntrack_zone tmp;
                             ^
   net/netfilter/nf_conntrack_core.c:1736:8: note: Shadow variable
      u32 tmp = hash_conntrack_raw(&tuple, rid, state->net);
          ^

vim +/tmp +1736 net/netfilter/nf_conntrack_core.c

  1702	
  1703	/* On success, returns 0, sets skb->_nfct | ctinfo */
  1704	static int
  1705	resolve_normal_ct(struct nf_conn *tmpl,
  1706			  struct sk_buff *skb,
  1707			  unsigned int dataoff,
  1708			  u_int8_t protonum,
  1709			  const struct nf_hook_state *state)
  1710	{
  1711		const struct nf_conntrack_zone *zone;
  1712		struct nf_conntrack_tuple tuple;
  1713		struct nf_conntrack_tuple_hash *h;
  1714		enum ip_conntrack_info ctinfo;
  1715		struct nf_conntrack_zone tmp;
  1716		u32 hash, zone_id, rid;
  1717		struct nf_conn *ct;
  1718	
  1719		if (!nf_ct_get_tuple(skb, skb_network_offset(skb),
  1720				     dataoff, state->pf, protonum, state->net,
  1721				     &tuple)) {
  1722			pr_debug("Can't get tuple\n");
  1723			return 0;
  1724		}
  1725	
  1726		/* look for tuple match */
  1727		zone = nf_ct_zone_tmpl(tmpl, skb, &tmp);
  1728	
  1729		zone_id = nf_ct_zone_id(zone, IP_CT_DIR_ORIGINAL);
  1730		hash = hash_conntrack_raw(&tuple, zone_id, state->net);
  1731		h = __nf_conntrack_find_get(state->net, zone, &tuple, hash);
  1732	
  1733		if (!h) {
  1734			rid = nf_ct_zone_id(zone, IP_CT_DIR_REPLY);
  1735			if (zone_id != rid) {
> 1736				u32 tmp = hash_conntrack_raw(&tuple, rid, state->net);
  1737	
  1738				h = __nf_conntrack_find_get(state->net, zone, &tuple, tmp);
  1739			}
  1740		}
  1741	
  1742		if (!h) {
  1743			h = init_conntrack(state->net, tmpl, &tuple,
  1744					   skb, dataoff, hash);
  1745			if (!h)
  1746				return 0;
  1747			if (IS_ERR(h))
  1748				return PTR_ERR(h);
  1749		}
  1750		ct = nf_ct_tuplehash_to_ctrack(h);
  1751	
  1752		/* It exists; we have (non-exclusive) reference. */
  1753		if (NF_CT_DIRECTION(h) == IP_CT_DIR_REPLY) {
  1754			ctinfo = IP_CT_ESTABLISHED_REPLY;
  1755		} else {
  1756			/* Once we've had two way comms, always ESTABLISHED. */
  1757			if (test_bit(IPS_SEEN_REPLY_BIT, &ct->status)) {
  1758				pr_debug("normal packet for %p\n", ct);
  1759				ctinfo = IP_CT_ESTABLISHED;
  1760			} else if (test_bit(IPS_EXPECTED_BIT, &ct->status)) {
  1761				pr_debug("related packet for %p\n", ct);
  1762				ctinfo = IP_CT_RELATED;
  1763			} else {
  1764				pr_debug("new packet for %p\n", ct);
  1765				ctinfo = IP_CT_NEW;
  1766			}
  1767		}
  1768		nf_ct_set(skb, ct, ctinfo);
  1769		return 0;
  1770	}
  1771	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

                 reply	other threads:[~2022-05-04  1:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202205040943.Gd2qI52I-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=fw@strlen.de \
    --cc=kbuild-all@lists.01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®