Re: [PATCH v4 12/14] selftests: harness: Stop using setjmp()/longjmp()
From: Nicolin Chen
Date: Tue Jun 10 2025 - 02:41:10 EST
Hi Thomas,
CC += Jason
On Mon, May 05, 2025 at 05:15:30PM +0200, Thomas Weißschuh wrote:
> Usage of longjmp() was added to ensure that teardown is always run in
> commit 63e6b2a42342 ("selftests/harness: Run TEARDOWN for ASSERT failures")
> However instead of calling longjmp() to the teardown handler it is easier to
> just call the teardown handler directly from __bail().
> Any potential duplicate teardown invocations are harmless as the actual
> handler will only ever be executed once since
> commit fff37bd32c76 ("selftests/harness: Fix fixture teardown").
>
> Additionally this removes a incompatibility with nolibc,
> which does not support setjmp()/longjmp().
>
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@xxxxxxxxxxxxx>
The iommufd selftest (CONFIG_IOMMUFD_TEST) starts to give warnings
when building with v6.16-rc1, though the test code wasn't changed
at these two functions:
------------------------------------------------------------------
make: Entering directory '/nicolinc/linux-stable/tools/testing/selftests/iommu'
CC iommufd
iommufd.c: In function ‘wrapper_iommufd_mock_domain_all_aligns’:
iommufd.c:1806:17: warning: ‘mfd’ may be used uninitialized in this function [-Wmaybe-uninitialized]
1806 | close(mfd);
| ^~~~~~~~~~
iommufd.c:1766:13: note: ‘mfd’ was declared here
1766 | int mfd;
| ^~~
iommufd.c: In function ‘wrapper_iommufd_mock_domain_all_aligns_copy’:
iommufd.c:1869:17: warning: ‘mfd’ may be used uninitialized in this function [-Wmaybe-uninitialized]
1869 | close(mfd);
| ^~~~~~~~~~
iommufd.c:1818:13: note: ‘mfd’ was declared here
1818 | int mfd;
| ^~~
CC iommufd_fail_nth
make: Leaving directory '/nicolinc/linux-stable/tools/testing/selftests/iommu'
------------------------------------------------------------------
Git bisect points to this patch, and reverting it fixes these.
Both mfds are under the same "if (variant->driver)" check, so the
warnings don't seem legit to me.
Do you have any idea why this happens?
Thanks
Nicolin