iommufd/selftest: Fix ioctl return value in _test_cmd_trigger_vevents()
PATCH 1/1 iommufd/selftest: Fix ioctl return value in _test_cmd_trigger_vevents()
The ioctl returns 0 upon success, so !0 returning -1 breaks the selftest.
Drop the '!' to fix it.
--- tools/testing/selftests/iommu/iommufd_utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/iommu/iommufd_utils.h +2 -2
@@ -1044,8 +1044,8 @@ static int _test_cmd_trigger_vevents(int fd, __u32 dev_id, __u32 nvevents) };while (nvevents--) { -if (!ioctl (fd,_IOMMU_TEST_CMD (IOMMU_TEST_OP_TRIGGER_VEVENT ), - &trigger_vevent_cmd)) +if (ioctl (fd,_IOMMU_TEST_CMD (IOMMU_TEST_OP_TRIGGER_VEVENT ), + &trigger_vevent_cmd))return -1 ; }return 0 ;
Signature · 1 line
2.43.0
Quoted 9 lines
From: Nicolin Chen <[email protected]>
Sent: Wednesday, October 15, 2025 5:49 AMThe ioctl returns 0 upon success, so !0 returning -1 breaks the selftest.
Drop the '!' to fix it.
Fixes 1d235d849425 ("iommu/selftest: prevent use of uninitialized variable")Signed-off-by Nicolin Chen <[email protected]>
Quoted 11 lines · Kevin
Quoted 9 lines
From: Nicolin Chen <[email protected]>
Sent: Wednesday, October 15, 2025 5:49 AMThe ioctl returns 0 upon success, so !0 returning -1 breaks the selftest.
Drop the '!' to fix it.
Fixes 1d235d849425 ("iommu/selftest: prevent use of uninitialized variable")Signed-off-by Nicolin Chen <[email protected]>Reviewed-by Kevin Tian <[email protected]>
With this fix a positive value returned by the ioctl() ends the loop and returns -1 to the assert.
Maybe better to put ioctl()<0 in the if condition?
Quoted 8 lines · Alessandro Zanni
Quoted 7 lines · Kevin
Quoted 7 lines
From: Nicolin Chen <[email protected]>
Sent: Wednesday, October 15, 2025 5:49 AMThe ioctl returns 0 upon success, so !0 returning -1 breaks the selftest.
Drop the '!' to fix it.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Fixes 1d235d849425 ("iommu/selftest: prevent use of uninitialized variable")Signed-off-by Nicolin Chen <[email protected]>Reviewed-by Kevin Tian <[email protected]>With this fix a positive value returned by the
ioctl()ends the loop and returns -1 to the assert.
Not with this particular ioctl(). And in fact, I don't recall we have an ioctl in iommufd uAPI that returns a positive value. All the other ioctls in selftest check "if (ret)".
Nicolin
Quoted 9 lines · Nicolin Chen
The ioctl returns 0 upon success, so !0 returning -1 breaks the selftest.
Drop the '!' to fix it.
Fixes 1d235d849425 ("iommu/selftest: prevent use of uninitialized variable")Signed-off-by Nicolin Chen <[email protected]>--- tools/testing/selftests/iommu/iommufd_utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Applied to for-rc, thanks
Jason