Messages in this thread | | | Date | Wed, 4 May 2022 09:39:30 +0800 | From | kernel test robot <> | Subject | net/netfilter/nf_conntrack_core.c:1736:8: warning: Local variable 'tmp' shadows outer variable [shadowVariable] |
| |
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
| |