Linux EXT4 FS development
 help / color / mirror / Atom feed
* [tytso-ext4:pu 4/50] fs/ext4/xattr-test.c:854:9: sparse: sparse: incorrect type in initializer (different base types)
@ 2026-11-12 13:59 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2026-11-12 13:59 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: oe-kbuild-all, linux-ext4

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git pu
head:   246d715a48c25a74ac372dda5e10d8f69f89b50a
commit: 64b5dfde9364204d0284d8800174ba8bb23d963f [4/50] ext4: add KUnit tests for fs/ext4/xattr.c
config: m68k-randconfig-r2311-20261112 (https://download.01.org/0day-ci/archive/20261112/202611121411.rRCBX7mS-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 8.5.0
sparse: v0.6.5-rc1-21-g84ec0658
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261112/202611121411.rRCBX7mS-lkp@intel.com/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@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202611121411.rRCBX7mS-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
>> fs/ext4/xattr-test.c:854:9: sparse: sparse: incorrect type in initializer (different base types) @@     expected long long left_value @@     got restricted __le32 const __left @@
   fs/ext4/xattr-test.c:854:9: sparse:     expected long long left_value
   fs/ext4/xattr-test.c:854:9: sparse:     got restricted __le32 const __left
>> fs/ext4/xattr-test.c:854:9: sparse: sparse: incorrect type in initializer (different base types) @@     expected long long right_value @@     got restricted __le32 const __right @@
   fs/ext4/xattr-test.c:854:9: sparse:     expected long long right_value
   fs/ext4/xattr-test.c:854:9: sparse:     got restricted __le32 const __right
   fs/ext4/xattr-test.c:999:9: sparse: sparse: incorrect type in initializer (different base types) @@     expected long long left_value @@     got restricted __le32 const __left @@
   fs/ext4/xattr-test.c:999:9: sparse:     expected long long left_value
   fs/ext4/xattr-test.c:999:9: sparse:     got restricted __le32 const __left
   fs/ext4/xattr-test.c:999:9: sparse: sparse: incorrect type in initializer (different base types) @@     expected long long right_value @@     got restricted __le32 const __right @@
   fs/ext4/xattr-test.c:999:9: sparse:     expected long long right_value
   fs/ext4/xattr-test.c:999:9: sparse:     got restricted __le32 const __right

vim +854 fs/ext4/xattr-test.c

   784	
   785	/*
   786	 * Test 3: In-inode (ibody) get/set, flags validation, EXT4_STATE_NEW handling,
   787	 * superblock feature update, and identical-value fastpath.
   788	 */
   789	static void test_xattr_ibody_basic_and_flags(struct kunit *test)
   790	{
   791		struct xattr_test_ctx *ctx = test->priv;
   792		struct inode *inode = &ctx->primary.ei.vfs_inode;
   793		struct ext4_inode *raw_inode = (struct ext4_inode *)ctx->primary.raw_buf;
   794		char long_name[260];
   795		char buf[32];
   796		unsigned int prev_dirty;
   797		int ret;
   798	
   799		/* Fresh inode without EXT4_STATE_XATTR returns -ENODATA */
   800		ret = ext4_xattr_get(inode, EXT4_XATTR_INDEX_USER, "missing",
   801				     buf, sizeof(buf));
   802		KUNIT_EXPECT_EQ(test, ret, -ENODATA);
   803	
   804		/* Parameter validation: NULL name -> -EINVAL, >255 name -> -ERANGE */
   805		ret = ext4_xattr_set_handle(NULL, inode, EXT4_XATTR_INDEX_USER,
   806					    NULL, "v", 1, 0);
   807		KUNIT_EXPECT_EQ(test, ret, -EINVAL);
   808	
   809		memset(long_name, 'x', sizeof(long_name) - 1);
   810		long_name[sizeof(long_name) - 1] = '\0';
   811		ret = ext4_xattr_set_handle(NULL, inode, EXT4_XATTR_INDEX_USER,
   812					    long_name, "v", 1, 0);
   813		KUNIT_EXPECT_EQ(test, ret, -ERANGE);
   814	
   815		/* Forced shutdown check on get and set */
   816		set_bit(EXT4_FLAGS_SHUTDOWN, &ctx->sbi.s_ext4_flags);
   817		KUNIT_EXPECT_EQ(test,
   818				ext4_xattr_get(inode, EXT4_XATTR_INDEX_USER, "k",
   819					       buf, sizeof(buf)),
   820				-EIO);
   821		KUNIT_EXPECT_EQ(test,
   822				ext4_xattr_set_handle(NULL, inode,
   823						      EXT4_XATTR_INDEX_USER, "k",
   824						      "v", 1, 0),
   825				-EIO);
   826		clear_bit(EXT4_FLAGS_SHUTDOWN, &ctx->sbi.s_ext4_flags);
   827	
   828		/* XATTR_REPLACE on non-existent attribute returns -ENODATA */
   829		ret = ext4_xattr_set_handle(NULL, inode, EXT4_XATTR_INDEX_USER,
   830					    "no_such", "val", 3, XATTR_REPLACE);
   831		KUNIT_EXPECT_EQ(test, ret, -ENODATA);
   832	
   833		/* Deleting non-existent attribute without XATTR_REPLACE succeeds (0) */
   834		ret = ext4_xattr_set_handle(NULL, inode, EXT4_XATTR_INDEX_USER,
   835					    "no_such", NULL, 0, 0);
   836		KUNIT_EXPECT_EQ(test, ret, 0);
   837	
   838		/*
   839		 * Verify EXT4_STATE_NEW causes ext4_xattr_set_handle() to zero the raw
   840		 * inode and clear EXT4_STATE_NEW.
   841		 */
   842		memset(raw_inode, 0x5a, TEST_INODE_SIZE);
   843		ext4_set_inode_state(inode, EXT4_STATE_NEW);
   844		KUNIT_EXPECT_FALSE(test,
   845				   ext4_has_feature_xattr(&ctx->sb));
   846	
   847		ret = ext4_xattr_set_handle(NULL, inode, EXT4_XATTR_INDEX_USER,
   848					    "key1", "hello", 5, XATTR_CREATE);
   849		KUNIT_ASSERT_EQ(test, ret, 0);
   850		KUNIT_EXPECT_EQ(test,
   851				ext4_test_inode_state(inode, EXT4_STATE_NEW), 0);
   852		KUNIT_EXPECT_NE(test,
   853				ext4_test_inode_state(inode, EXT4_STATE_XATTR), 0);
 > 854		KUNIT_EXPECT_EQ(test, IHDR(inode, raw_inode)->h_magic,
   855				cpu_to_le32(EXT4_XATTR_MAGIC));
   856		/* Setting first xattr enables EXT4_FEATURE_COMPAT_EXT_ATTR on sb */
   857		KUNIT_EXPECT_TRUE(test, ext4_has_feature_xattr(&ctx->sb));
   858	
   859		/* XATTR_CREATE on existing attribute returns -EEXIST */
   860		ret = ext4_xattr_set_handle(NULL, inode, EXT4_XATTR_INDEX_USER,
   861					    "key1", "other", 5, XATTR_CREATE);
   862		KUNIT_EXPECT_EQ(test, ret, -EEXIST);
   863	
   864		/* Query length (NULL buffer), too small buffer (-ERANGE), and read */
   865		ret = ext4_xattr_get(inode, EXT4_XATTR_INDEX_USER, "key1", NULL, 0);
   866		KUNIT_EXPECT_EQ(test, ret, 5);
   867	
   868		ret = ext4_xattr_get(inode, EXT4_XATTR_INDEX_USER, "key1", buf, 4);
   869		KUNIT_EXPECT_EQ(test, ret, -ERANGE);
   870	
   871		memset(buf, 0, sizeof(buf));
   872		ret = ext4_xattr_get(inode, EXT4_XATTR_INDEX_USER, "key1",
   873				     buf, sizeof(buf));
   874		KUNIT_EXPECT_EQ(test, ret, 5);
   875		KUNIT_EXPECT_MEMEQ(test, buf, "hello", 5);
   876	
   877		/* Direct ext4_xattr_ibody_get() check */
   878		memset(buf, 0, sizeof(buf));
   879		ret = ext4_xattr_ibody_get(inode, EXT4_XATTR_INDEX_USER, "key1",
   880					   buf, sizeof(buf));
   881		KUNIT_EXPECT_EQ(test, ret, 5);
   882		KUNIT_EXPECT_MEMEQ(test, buf, "hello", 5);
   883	
   884		/*
   885		 * Setting the exact same value triggers the ext4_xattr_value_same()
   886		 * fastpath and skips dirtying the inode location.
   887		 */
   888		prev_dirty = ctx->mark_iloc_dirty_calls;
   889		ret = ext4_xattr_set_handle(NULL, inode, EXT4_XATTR_INDEX_USER,
   890					    "key1", "hello", 5, XATTR_REPLACE);
   891		KUNIT_EXPECT_EQ(test, ret, 0);
   892		KUNIT_EXPECT_EQ(test, ctx->mark_iloc_dirty_calls, prev_dirty);
   893	}
   894	

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-12 13:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-12 13:59 [tytso-ext4:pu 4/50] fs/ext4/xattr-test.c:854:9: sparse: sparse: incorrect type in initializer (different base types) kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox