[mark:treewide/gnu99 1/1] net/netfilter/xt_hashlimit.c:608:40: warning: left shift of negative value

From: kernel test robot
Date: Wed Jan 12 2022 - 17:59:27 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git treewide/gnu99
head: df0f3c59f076be0ab4a6d8de53fdeef871394594
commit: df0f3c59f076be0ab4a6d8de53fdeef871394594 [1/1] treewide: use -std=gnu99
config: m68k-defconfig (https://download.01.org/0day-ci/archive/20220113/202201130653.9pXG19yX-lkp@xxxxxxxxx/config)
compiler: m68k-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git/commit/?id=df0f3c59f076be0ab4a6d8de53fdeef871394594
git remote add mark https://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git
git fetch --no-tags mark treewide/gnu99
git checkout df0f3c59f076be0ab4a6d8de53fdeef871394594
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=m68k SHELL=/bin/bash drivers/block/drbd/ net/netfilter/

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

All warnings (new ones prefixed by >>):

In file included from include/linux/byteorder/big_endian.h:5,
from arch/m68k/include/uapi/asm/byteorder.h:5,
from include/asm-generic/bitops/le.h:7,
from arch/m68k/include/asm/bitops.h:529,
from include/linux/bitops.h:33,
from include/linux/thread_info.h:27,
from include/asm-generic/preempt.h:5,
from ./arch/m68k/include/generated/asm/preempt.h:1,
from include/linux/preempt.h:78,
from arch/m68k/include/asm/irqflags.h:6,
from include/linux/irqflags.h:16,
from arch/m68k/include/asm/atomic.h:6,
from include/linux/atomic.h:7,
from include/linux/mm_types_task.h:13,
from include/linux/mm_types.h:5,
from include/linux/buildid.h:5,
from include/linux/module.h:14,
from net/netfilter/xt_hashlimit.c:13:
net/netfilter/xt_hashlimit.c: In function 'maskl':
>> net/netfilter/xt_hashlimit.c:608:40: warning: left shift of negative value [-Wshift-negative-value]
608 | return l ? htonl(ntohl(a) & ~0 << (32 - l)) : 0;
| ^~
include/uapi/linux/byteorder/big_endian.h:40:51: note: in definition of macro '__cpu_to_be32'
40 | #define __cpu_to_be32(x) ((__force __be32)(__u32)(x))
| ^
include/linux/byteorder/generic.h:139:18: note: in expansion of macro '___htonl'
139 | #define htonl(x) ___htonl(x)
| ^~~~~~~~
net/netfilter/xt_hashlimit.c:608:20: note: in expansion of macro 'htonl'
608 | return l ? htonl(ntohl(a) & ~0 << (32 - l)) : 0;
| ^~~~~
--
drivers/block/drbd/drbd_main.c: In function 'dcbp_set_pad_bits':
>> drivers/block/drbd/drbd_main.c:1095:44: warning: left shift of negative value [-Wshift-negative-value]
1095 | p->encoding = (p->encoding & (~0x7 << 4)) | (n << 4);
| ^~


vim +608 net/netfilter/xt_hashlimit.c

817e076f61bca3 Florian Westphal 2012-05-07 605
09e410def64324 Jan Engelhardt 2008-01-31 606 static inline __be32 maskl(__be32 a, unsigned int l)
09e410def64324 Jan Engelhardt 2008-01-31 607 {
1b9b70ea2ebaab Patrick McHardy 2008-04-09 @608 return l ? htonl(ntohl(a) & ~0 << (32 - l)) : 0;
09e410def64324 Jan Engelhardt 2008-01-31 609 }
09e410def64324 Jan Engelhardt 2008-01-31 610

:::::: The code at line 608 was first introduced by commit
:::::: 1b9b70ea2ebaab26c3e4fed385dfab6fc16359ed [NETFILTER]: xt_hashlimit: fix mask calculation

:::::: TO: Patrick McHardy <kaber@xxxxxxxxx>
:::::: CC: David S. Miller <davem@xxxxxxxxxxxxx>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx