[groeck-staging:testing 10/11] lib/checksum_kunit.c:512:53: sparse: sparse: incorrect type in argument 5 (different base types)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git testing
head:   87a37f01e744b2203a6d053322632f680f30fade
commit: 068e2e1754d7c9e92e07c8332b2b64673b4989cc [10/11] lib: checksum: Add some corner cases to csum_ipv6_magic tests
config: x86_64-randconfig-122-20240218 (https://download.01.org/0day-ci/archive/20240219/202402190049.MS7cVVET-lkp@xxxxxxxxx/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240219/202402190049.MS7cVVET-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/202402190049.MS7cVVET-lkp@xxxxxxxxx/

sparse warnings: (new ones prefixed by >>)
>> lib/checksum_kunit.c:512:53: sparse: sparse: incorrect type in argument 5 (different base types) @@     expected restricted __wsum [usertype] csum @@     got unsigned int @@
   lib/checksum_kunit.c:512:53: sparse:     expected restricted __wsum [usertype] csum
   lib/checksum_kunit.c:512:53: sparse:     got unsigned int
   lib/checksum_kunit.c:517:50: sparse: sparse: incorrect type in argument 5 (different base types) @@     expected restricted __wsum [usertype] csum @@     got unsigned int @@
   lib/checksum_kunit.c:517:50: sparse:     expected restricted __wsum [usertype] csum
   lib/checksum_kunit.c:517:50: sparse:     got unsigned int
   lib/checksum_kunit.c:522:50: sparse: sparse: incorrect type in argument 5 (different base types) @@     expected restricted __wsum [usertype] csum @@     got unsigned int @@
   lib/checksum_kunit.c:522:50: sparse:     expected restricted __wsum [usertype] csum
   lib/checksum_kunit.c:522:50: sparse:     got unsigned int
   lib/checksum_kunit.c:527:48: sparse: sparse: incorrect type in argument 5 (different base types) @@     expected restricted __wsum [usertype] csum @@     got unsigned int @@
   lib/checksum_kunit.c:527:48: sparse:     expected restricted __wsum [usertype] csum
   lib/checksum_kunit.c:527:48: sparse:     got unsigned int
   lib/checksum_kunit.c:532:48: sparse: sparse: incorrect type in argument 5 (different base types) @@     expected restricted __wsum [usertype] csum @@     got unsigned int @@
   lib/checksum_kunit.c:532:48: sparse:     expected restricted __wsum [usertype] csum
   lib/checksum_kunit.c:532:48: sparse:     got unsigned int
>> lib/checksum_kunit.c:542:53: sparse: sparse: incorrect type in argument 5 (different base types) @@     expected restricted __wsum [usertype] csum @@     got restricted __be32 [usertype] @@
   lib/checksum_kunit.c:542:53: sparse:     expected restricted __wsum [usertype] csum
   lib/checksum_kunit.c:542:53: sparse:     got restricted __be32 [usertype]

vim +512 lib/checksum_kunit.c

   480	
   481	static void test_csum_ipv6_magic(struct kunit *test)
   482	{
   483	#if defined(CONFIG_NET)
   484		struct csum_ipv6_magic_data {
   485			const struct in6_addr saddr;
   486			const struct in6_addr daddr;
   487			__be32 len;
   488			__wsum csum;
   489			unsigned char proto;
   490			unsigned char pad[3];
   491		} *data;
   492		__sum16 csum_result, expected;
   493		int ipv6_num_tests = ((MAX_LEN - sizeof(struct csum_ipv6_magic_data)) / WORD_ALIGNMENT);
   494	
   495		for (int i = 0; i < ipv6_num_tests; i++) {
   496			int index = i * WORD_ALIGNMENT;
   497	
   498			data = kmalloc(sizeof(struct csum_ipv6_magic_data), GFP_KERNEL);
   499	
   500			memcpy(data, random_buf + index, sizeof(struct csum_ipv6_magic_data));
   501	
   502			csum_result = csum_ipv6_magic(&data->saddr, &data->daddr,
   503						      ntohl(data->len), data->proto,
   504						      data->csum);
   505			expected = (__force __sum16)htons(expected_csum_ipv6_magic[i]);
   506			CHECK_EQ(csum_result, expected);
   507		}
   508	
   509		/* test corner cases */
   510		memset(tmp_buf, 0xff, sizeof(struct in6_addr));
   511		csum_result = csum_ipv6_magic((struct in6_addr *)tmp_buf, (struct in6_addr *)tmp_buf,
 > 512					      0xffff, 0xff, 0xffffffff);
   513		expected = (__force __sum16)htons(expected_csum_ipv6_magic_corner[0]);
   514		CHECK_EQ(csum_result, expected);
   515	
   516		csum_result = csum_ipv6_magic((struct in6_addr *)tmp_buf, (struct in6_addr *)tmp_buf,
   517					      0xffff, 0, 0xffffffff);
   518		expected = (__force __sum16)htons(expected_csum_ipv6_magic_corner[1]);
   519		CHECK_EQ(csum_result, expected);
   520	
   521		csum_result = csum_ipv6_magic((struct in6_addr *)tmp_buf, (struct in6_addr *)tmp_buf,
   522					      0xffff, 1, 0xffffffff);
   523		expected = (__force __sum16)htons(expected_csum_ipv6_magic_corner[2]);
   524		CHECK_EQ(csum_result, expected);
   525	
   526		csum_result = csum_ipv6_magic((struct in6_addr *)tmp_buf, (struct in6_addr *)tmp_buf,
   527					      0, 0xff, 0xffffffff);
   528		expected = (__force __sum16)htons(expected_csum_ipv6_magic_corner[3]);
   529		CHECK_EQ(csum_result, expected);
   530	
   531		csum_result = csum_ipv6_magic((struct in6_addr *)tmp_buf, (struct in6_addr *)tmp_buf,
   532					      1, 0xff, 0xffffffff);
   533		expected = (__force __sum16)htons(expected_csum_ipv6_magic_corner[4]);
   534		CHECK_EQ(csum_result, expected);
   535	
   536		csum_result = csum_ipv6_magic((struct in6_addr *)tmp_buf, (struct in6_addr *)tmp_buf,
   537					      0xffff, 0xff, 0);
   538		expected = (__force __sum16)htons(expected_csum_ipv6_magic_corner[5]);
   539		CHECK_EQ(csum_result, expected);
   540	
   541		csum_result = csum_ipv6_magic((struct in6_addr *)tmp_buf, (struct in6_addr *)tmp_buf,
 > 542					      0xffff, 0xff, htonl(1));
   543		expected = (__force __sum16)htons(expected_csum_ipv6_magic_corner[6]);
   544		CHECK_EQ(csum_result, expected);
   545	

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




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux