mirror of
https://github.com/torvalds/linux.git
synced 2026-11-20 13:03:48 +00:00
vfs: use __struct_size() in the fdtable KUnit test
sparse doesn't know __builtin_dynamic_object_size() and so the two size
checks in the fdtable test fall apart on every config where the compiler
has __counted_by_ptr:
fs/tests/fdtable_kunit.c:25:9: sparse: undefined identifier '__builtin_dynamic_object_size'
fs/tests/fdtable_kunit.c:25:9: sparse: incompatible types for operation (==):
Use __struct_size() instead. Every compiler that has __counted_by_ptr also
has __builtin_dynamic_object_size() so it expands to the same builtin and
the test checks the same thing. sparse lacks the builtin and gets the
__builtin_object_size() fallback which it does understand.
Fixes: 501cbbd276 ("vfs: Add KUnit tests for fdtable")
Reported-by: kernel test robot <[email protected]>
Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
Signed-off-by: Christian Brauner (Amutable) <[email protected]>
This commit is contained in:
@@ -22,7 +22,7 @@ static void test_alloc_fdtable(struct kunit *test)
|
||||
* __counted_by_ptr.
|
||||
*/
|
||||
#ifdef CONFIG_CC_HAS_COUNTED_BY_PTR
|
||||
KUNIT_EXPECT_EQ(test, __builtin_dynamic_object_size(fdt->fd, 0),
|
||||
KUNIT_EXPECT_EQ(test, __struct_size(fdt->fd),
|
||||
fdt->max_fds * sizeof(struct file *));
|
||||
#endif
|
||||
|
||||
@@ -51,7 +51,7 @@ static void test_dup_fd(struct kunit *test)
|
||||
* __counted_by_ptr.
|
||||
*/
|
||||
#ifdef CONFIG_CC_HAS_COUNTED_BY_PTR
|
||||
KUNIT_EXPECT_EQ(test, __builtin_dynamic_object_size(fdt->fd, 0),
|
||||
KUNIT_EXPECT_EQ(test, __struct_size(fdt->fd),
|
||||
fdt->max_fds * sizeof(struct file *));
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user