selftests/configfs: fix the build on 32-bit architectures
PATCH 1/1 selftests/configfs: fix the build on 32-bit architectures
The fixture setup checks the result of mkdtemp() with ASSERT_NE(), which hands the pointer to the harness. The harness casts both operands to intmax_t to print them, and on 32-bit architectures gcc warns about the cast from a pointer to an integer of a different size. The configfs test builds with -Werror, so it fails to build there:
kselftest_harness.h:797:49: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
Compare the result against NULL inside ASSERT_TRUE(), so that the harness only sees an int.
---
KernelCI's 32-bit arm kselftest builds fail on this. Built configfs_test.c with gcc 16 -m32, with and without _TIME_BITS=64 (fails before, builds after), clang 21 -m32, and both compilers for x86_64.
The harness cast warns for every pointer comparison on 32-bit, a few thousand warnings in one KernelCI arm build, and configfs only breaks because of its -Werror. Making the harness print pointers through uintptr_t would be a separate change.
tools/testing/selftests/filesystems/configfs/configfs_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/filesystems/configfs/configfs_test.c +1 -1
@@ -122,7 +122,7 @@ FIXTURE_SETUP(configfs)ASSERT_EQ (unshare (CLONE_NEWNS ),0 );ASSERT_EQ (mount (NULL ,"/" ,NULL ,MS_REC |MS_PRIVATE ,NULL ),0 ); -ASSERT_NE (mkdtemp (tmpl),NULL ); +ASSERT_TRUE (mkdtemp (tmpl) !=NULL );strcpy (self->mnt, tmpl);ASSERT_EQ (mount ("configfs" , self->mnt,"configfs" ,0 ,NULL ),0 );
Signature · 1 line
2.53.0
Quoted 6 lines · Sasha Levin
The fixture setup checks the result of
mkdtemp()withASSERT_NE(), which hands the pointer to the harness. The harness casts both operands tointmax_tto print them, and on 32-bit architectures gcc warns about the cast from a pointer to an integer of a different size. The configfs test builds with -Werror, so it fails to build there:
Quoted 7 lines
kselftest_harness.h:797:49: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
Compare the result against NULL inside
ASSERT_TRUE(), so that the harness only sees an int.Fixes a7fdcb2edd0f ("selftests/configfs: add tests for the userspace interface")Signed-off-by Sasha Levin <[email protected]>
Thanks for the fix.
Quoted 9 lines
---
KernelCI's 32-bit arm kselftest builds fail on this. Builtconfigfs_test.cwith gcc 16 -m32, with and without _TIME_BITS=64 (fails before, builds after), clang 21 -m32, and both compilers forx86_64.The harness cast warns for every pointer comparison on 32-bit, a few thousand warnings in one KernelCI arm build, and configfs only breaks because of its -Werror. Making the harness print pointers through
uintptr_twould be a separate change.
Christophe posted a harness fix for this in January, but it was never merged?
https://lore.kernel.org/all/948937bfe461cf0fb6ade2623e51f673f845fa51.1768298756.git.chleroy@kernel.org/
It still applies to linux-next, and with it configfs_test.c compiles on 32-bit without this patch.
Either way, I will merge your patch tomorrow if no other review pops up.
Thanks,
--breno
Quoted 9 lines · Sasha Levin
The fixture setup checks the result of
mkdtemp()withASSERT_NE(), which hands the pointer to the harness. The harness casts both operands tointmax_tto print them, and on 32-bit architectures gcc warns about the cast from a pointer to an integer of a different size. The configfs test builds with -Werror, so it fails to build there:kselftest_harness.h:797:49: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
[...]
Applied, thanks!
[1/1] selftests/configfs: fix the build on 32-bit architectures
https://git.kernel.org/pub/scm/linux/kernel/git/leitao/linux.git/commit/?id=57d94d26ed42
Best regards,
Signature · 1 line
Breno Leitao <[email protected]>