lib/overflow_kunit.c:998:9: sparse: sparse: cast truncates bits from constant value (ffffff01 becomes 1)

From: kernel test robot
Date: Wed Jan 10 2024 - 07:01:15 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: ab27740f76654ed58dd32ac0ba0031c18a6dea3b
commit: 4b21d25bf519c9487935a664886956bb18f04f6d overflow: Introduce overflows_type() and castable_to_type()
date: 1 year, 2 months ago
config: arm-randconfig-r122-20240105 (https://download.01.org/0day-ci/archive/20240110/202401101916.N7fPxjk2-lkp@xxxxxxxxx/config)
compiler: arm-linux-gnueabi-gcc (GCC) 13.2.0
reproduce: (https://download.01.org/0day-ci/archive/20240110/202401101916.N7fPxjk2-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/202401101916.N7fPxjk2-lkp@xxxxxxxxx/

sparse warnings: (new ones prefixed by >>)
lib/overflow_kunit.c:300:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:300:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:300:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:300:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:300:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:300:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:300:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:300:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:301:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:301:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:301:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:301:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:301:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:301:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:301:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:301:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:301:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:301:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:302:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:302:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:302:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:302:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:302:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:302:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:302:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:302:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:302:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:302:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:303:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:303:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:303:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:303:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:303:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:303:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:303:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:303:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:303:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:303:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:304:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:304:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:304:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:304:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:304:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:304:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:304:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:304:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:304:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:304:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:313:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:313:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:313:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:313:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:313:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:313:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:313:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:313:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:313:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:313:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:319:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:319:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:319:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:319:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:319:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:319:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:319:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:319:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:319:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:319:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:326:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:326:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:326:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:326:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:326:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:326:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:326:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:326:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:326:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:326:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:333:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:333:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:333:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:333:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:333:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:333:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:333:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:333:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:333:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:333:1: sparse: sparse: self-comparison always evaluates to true
lib/overflow_kunit.c:427:9: sparse: sparse: cast truncates bits from constant value (12c becomes 2c)
lib/overflow_kunit.c:429:9: sparse: sparse: cast truncates bits from constant value (1112c becomes 112c)
lib/overflow_kunit.c:431:9: sparse: sparse: cast truncates bits from constant value (10811112c becomes 811112c)
lib/overflow_kunit.c:432:9: sparse: sparse: cast truncates bits from constant value (10811112c becomes 811112c)
lib/overflow_kunit.c:449:9: sparse: sparse: cast truncates bits from constant value (12c becomes 2c)
lib/overflow_kunit.c:451:9: sparse: sparse: cast truncates bits from constant value (1112c becomes 112c)
lib/overflow_kunit.c:453:9: sparse: sparse: cast truncates bits from constant value (10811112c becomes 811112c)
lib/overflow_kunit.c:454:9: sparse: sparse: cast truncates bits from constant value (10811112c becomes 811112c)
lib/overflow_kunit.c:466:9: sparse: sparse: cast truncates bits from constant value (100 becomes 0)
lib/overflow_kunit.c:468:9: sparse: sparse: cast truncates bits from constant value (10000 becomes 0)
lib/overflow_kunit.c:470:9: sparse: sparse: cast truncates bits from constant value (100000000 becomes 0)
lib/overflow_kunit.c:471:9: sparse: sparse: cast truncates bits from constant value (100000000 becomes 0)
>> lib/overflow_kunit.c:998:9: sparse: sparse: cast truncates bits from constant value (ffffff01 becomes 1)
>> lib/overflow_kunit.c:998:9: sparse: sparse: cast truncates bits from constant value (ffffff01 becomes 1)
>> lib/overflow_kunit.c:998:9: sparse: sparse: cast truncates bits from constant value (ffffff01 becomes 1)
>> lib/overflow_kunit.c:998:9: sparse: sparse: cast truncates bits from constant value (ffff0001 becomes 1)
>> lib/overflow_kunit.c:998:9: sparse: sparse: cast truncates bits from constant value (ffffff01 becomes 1)
>> lib/overflow_kunit.c:998:9: sparse: sparse: cast truncates bits from constant value (ffffff01 becomes 1)
>> lib/overflow_kunit.c:998:9: sparse: sparse: cast truncates bits from constant value (ffffff01 becomes 1)
>> lib/overflow_kunit.c:998:9: sparse: sparse: cast truncates bits from constant value (ffffff01 becomes 1)
lib/overflow_kunit.c:999:9: sparse: sparse: cast truncates bits from constant value (ffff0001 becomes 1)
lib/overflow_kunit.c:999:9: sparse: sparse: cast truncates bits from constant value (ffffff01 becomes 1)
lib/overflow_kunit.c:999:9: sparse: sparse: cast truncates bits from constant value (ffff0001 becomes 1)
lib/overflow_kunit.c:999:9: sparse: sparse: cast truncates bits from constant value (ffff0001 becomes 1)
lib/overflow_kunit.c:999:9: sparse: sparse: cast truncates bits from constant value (ffff0001 becomes 1)
lib/overflow_kunit.c:999:9: sparse: sparse: cast truncates bits from constant value (ffff0001 becomes 1)
lib/overflow_kunit.c:999:9: sparse: sparse: cast truncates bits from constant value (ffff0001 becomes 1)
lib/overflow_kunit.c:999:9: sparse: sparse: cast truncates bits from constant value (ffff0001 becomes 1)
lib/overflow_kunit.c:1000:9: sparse: sparse: cast truncates bits from constant value (ffffff01 becomes 1)
lib/overflow_kunit.c:1000:9: sparse: sparse: cast truncates bits from constant value (ffff0001 becomes 1)
lib/overflow_kunit.c:1001:9: sparse: sparse: cast truncates bits from constant value (ffffff01 becomes 1)
lib/overflow_kunit.c:1001:9: sparse: sparse: cast truncates bits from constant value (ffff0001 becomes 1)
lib/overflow_kunit.c:1002:9: sparse: sparse: cast truncates bits from constant value (ffffff01 becomes 1)
lib/overflow_kunit.c:1002:9: sparse: sparse: cast truncates bits from constant value (ffff0001 becomes 1)
lib/overflow_kunit.c:1003:9: sparse: sparse: cast truncates bits from constant value (ffffff01 becomes 1)
lib/overflow_kunit.c:1003:9: sparse: sparse: cast truncates bits from constant value (ffff0001 becomes 1)
lib/overflow_kunit.c:1098:9: sparse: sparse: cast truncates bits from constant value (ffffff01 becomes 1)
lib/overflow_kunit.c:1098:9: sparse: sparse: cast truncates bits from constant value (ffffff01 becomes 1)
lib/overflow_kunit.c:1098:9: sparse: sparse: cast truncates bits from constant value (ffffff01 becomes 1)
lib/overflow_kunit.c:1099:9: sparse: sparse: cast truncates bits from constant value (ffff0001 becomes 1)
lib/overflow_kunit.c:1099:9: sparse: sparse: cast truncates bits from constant value (ffff0001 becomes 1)
lib/overflow_kunit.c:1099:9: sparse: sparse: cast truncates bits from constant value (ffff0001 becomes 1)

vim +998 lib/overflow_kunit.c

997
> 998 TEST_TYPE_SETS(u8, true, false, false, false, false, false, false, false);
999 TEST_TYPE_SETS(u16, false, true, false, false, false, false, false, false);
1000 TEST_TYPE_SETS(u32, false, false, true, false, false, false, false, false);
1001 TEST_TYPE_SETS(s8, false, false, false, true, false, false, false, false);
1002 TEST_TYPE_SETS(s16, false, false, false, false, true, false, false, false);
1003 TEST_TYPE_SETS(s32, false, false, false, false, false, true, false, false);
1004 #if BITS_PER_LONG == 64
1005 TEST_TYPE_SETS(u64, false, false, false, false, false, false, true, false);
1006 TEST_TYPE_SETS(s64, false, false, false, false, false, false, false, true);
1007 #endif
1008
1009 /* Check for macro side-effects. */
1010 var = 4;
1011 KUNIT_EXPECT_EQ(test, var, 4);
1012 KUNIT_EXPECT_TRUE(test, __same_type(var++, int));
1013 KUNIT_EXPECT_EQ(test, var, 4);
1014 KUNIT_EXPECT_TRUE(test, __same_type(int, var++));
1015 KUNIT_EXPECT_EQ(test, var, 4);
1016 KUNIT_EXPECT_TRUE(test, __same_type(var++, var++));
1017 KUNIT_EXPECT_EQ(test, var, 4);
1018
1019 kunit_info(test, "%d __same_type() tests finished\n", count);
1020

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