arch/arc/include/asm/checksum.h:27:26: sparse: sparse: restricted __wsum degrades to integer

From: kernel test robot
Date: Wed Dec 13 2023 - 18:57:22 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 5bd7ef53ffe5ca580e93e74eb8c81ed191ddc4bd
commit: b38460bc463c54e0c15ff3b37e81f7e2059bb9bb kunit: Fix checksum tests on big endian CPUs
date: 4 months ago
config: arc-randconfig-r121-20231111 (https://download.01.org/0day-ci/archive/20231214/202312140758.j0bflCSo-lkp@xxxxxxxxx/config)
compiler: arceb-elf-gcc (GCC) 13.2.0
reproduce: (https://download.01.org/0day-ci/archive/20231214/202312140758.j0bflCSo-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202312140758.j0bflCSo-lkp@xxxxxxxxx/

sparse warnings: (new ones prefixed by >>)
lib/checksum_kunit.c: note: in included file:
>> arch/arc/include/asm/checksum.h:27:26: sparse: sparse: restricted __wsum degrades to integer
arch/arc/include/asm/checksum.h:27:36: sparse: sparse: restricted __wsum degrades to integer
>> arch/arc/include/asm/checksum.h:29:11: sparse: sparse: bad assignment (-=) to restricted __wsum
arch/arc/include/asm/checksum.h:30:16: sparse: sparse: restricted __wsum degrades to integer
>> arch/arc/include/asm/checksum.h:30:18: sparse: sparse: incorrect type in return expression (different base types) @@ expected restricted __sum16 @@ got unsigned int @@
arch/arc/include/asm/checksum.h:30:18: sparse: expected restricted __sum16
arch/arc/include/asm/checksum.h:30:18: sparse: got unsigned int
>> arch/arc/include/asm/checksum.h:27:26: sparse: sparse: restricted __wsum degrades to integer
arch/arc/include/asm/checksum.h:27:36: sparse: sparse: restricted __wsum degrades to integer
>> arch/arc/include/asm/checksum.h:29:11: sparse: sparse: bad assignment (-=) to restricted __wsum
arch/arc/include/asm/checksum.h:30:16: sparse: sparse: restricted __wsum degrades to integer
>> arch/arc/include/asm/checksum.h:30:18: sparse: sparse: incorrect type in return expression (different base types) @@ expected restricted __sum16 @@ got unsigned int @@
arch/arc/include/asm/checksum.h:30:18: sparse: expected restricted __sum16
arch/arc/include/asm/checksum.h:30:18: sparse: got unsigned int
>> arch/arc/include/asm/checksum.h:27:26: sparse: sparse: restricted __wsum degrades to integer
arch/arc/include/asm/checksum.h:27:36: sparse: sparse: restricted __wsum degrades to integer
>> arch/arc/include/asm/checksum.h:29:11: sparse: sparse: bad assignment (-=) to restricted __wsum
arch/arc/include/asm/checksum.h:30:16: sparse: sparse: restricted __wsum degrades to integer
>> arch/arc/include/asm/checksum.h:30:18: sparse: sparse: incorrect type in return expression (different base types) @@ expected restricted __sum16 @@ got unsigned int @@
arch/arc/include/asm/checksum.h:30:18: sparse: expected restricted __sum16
arch/arc/include/asm/checksum.h:30:18: sparse: got unsigned int
>> arch/arc/include/asm/checksum.h:27:26: sparse: sparse: restricted __wsum degrades to integer
arch/arc/include/asm/checksum.h:27:36: sparse: sparse: restricted __wsum degrades to integer
>> arch/arc/include/asm/checksum.h:29:11: sparse: sparse: bad assignment (-=) to restricted __wsum
arch/arc/include/asm/checksum.h:30:16: sparse: sparse: restricted __wsum degrades to integer
>> arch/arc/include/asm/checksum.h:30:18: sparse: sparse: incorrect type in return expression (different base types) @@ expected restricted __sum16 @@ got unsigned int @@
arch/arc/include/asm/checksum.h:30:18: sparse: expected restricted __sum16
arch/arc/include/asm/checksum.h:30:18: sparse: got unsigned int
>> arch/arc/include/asm/checksum.h:27:26: sparse: sparse: restricted __wsum degrades to integer
arch/arc/include/asm/checksum.h:27:36: sparse: sparse: restricted __wsum degrades to integer
>> arch/arc/include/asm/checksum.h:29:11: sparse: sparse: bad assignment (-=) to restricted __wsum
arch/arc/include/asm/checksum.h:30:16: sparse: sparse: restricted __wsum degrades to integer
>> arch/arc/include/asm/checksum.h:30:18: sparse: sparse: incorrect type in return expression (different base types) @@ expected restricted __sum16 @@ got unsigned int @@
arch/arc/include/asm/checksum.h:30:18: sparse: expected restricted __sum16
arch/arc/include/asm/checksum.h:30:18: sparse: got unsigned int

vim +27 arch/arc/include/asm/checksum.h

ca15c8ecd588dd Vineet Gupta 2013-01-18 18
ca15c8ecd588dd Vineet Gupta 2013-01-18 19 /*
ca15c8ecd588dd Vineet Gupta 2013-01-18 20 * Fold a partial checksum
ca15c8ecd588dd Vineet Gupta 2013-01-18 21 *
ca15c8ecd588dd Vineet Gupta 2013-01-18 22 * The 2 swords comprising the 32bit sum are added, any carry to 16th bit
ca15c8ecd588dd Vineet Gupta 2013-01-18 23 * added back and final sword result inverted.
ca15c8ecd588dd Vineet Gupta 2013-01-18 24 */
ca15c8ecd588dd Vineet Gupta 2013-01-18 25 static inline __sum16 csum_fold(__wsum s)
ca15c8ecd588dd Vineet Gupta 2013-01-18 26 {
d4067395519b40 Jinchao Wang 2021-06-26 @27 unsigned int r = s << 16 | s >> 16; /* ror */
ca15c8ecd588dd Vineet Gupta 2013-01-18 28 s = ~s;
ca15c8ecd588dd Vineet Gupta 2013-01-18 @29 s -= r;
ca15c8ecd588dd Vineet Gupta 2013-01-18 @30 return s >> 16;
ca15c8ecd588dd Vineet Gupta 2013-01-18 31 }
ca15c8ecd588dd Vineet Gupta 2013-01-18 32

:::::: The code at line 27 was first introduced by commit
:::::: d4067395519b40d4ee9b7c26347233e4ae59f900 arc: Prefer unsigned int to bare use of unsigned

:::::: TO: Jinchao Wang <wjc@xxxxxxxxxx>
:::::: CC: Vineet Gupta <vgupta@xxxxxxxxxxxx>

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki