Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Shuah Khan <skhan@linuxfoundation.org>
To: Alessandro Zanni <alessandro.zanni87@gmail.com>,
	jgg@ziepe.ca, kevin.tian@intel.com, shuah@kernel.org
Cc: iommu@lists.linux.dev, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH v2] Fix to avoid the usage of the `res` variable uninitialized in the following macro expansions.
Date: Tue, 7 Oct 2025 15:28:29 -0600	[thread overview]
Message-ID: <dc360969-c1af-4b87-a259-cc265a8d553d@linuxfoundation.org> (raw)
In-Reply-To: <20250924165801.49523-1-alessandro.zanni87@gmail.com>

On 9/24/25 10:57, Alessandro Zanni wrote:

Fix to avoid the usage of the `res` variable uninitialized in the following macro expansions.

ret not res?

You can simplify the shortlog "Fix ret unitialized warning" perhaps.


> It solves the following warning:

Fix the following warning.

> In function ‘iommufd_viommu_vdevice_alloc’,
>    inlined from ‘wrapper_iommufd_viommu_vdevice_alloc’ at
> iommufd.c:2889:1:
> ../kselftest_harness.h:760:12: warning: ‘ret’ may be used uninitialized
> [-Wmaybe-uninitialized]
>    760 |   if (!(__exp _t __seen)) { \
>        |      ^
> ../kselftest_harness.h:513:9: note: in expansion of macro ‘__EXPECT’
>    513 |   __EXPECT(expected, #expected, seen, #seen, ==, 1)
>        |   ^~~~~~~~
> iommufd_utils.h:1057:9: note: in expansion of macro ‘ASSERT_EQ’
>   1057 |   ASSERT_EQ(0, _test_cmd_trigger_vevents(self->fd, dev_id,
> nvevents))
>        |   ^~~~~~~~~
> iommufd.c:2924:17: note: in expansion of macro
> ‘test_cmd_trigger_vevents’
>   2924 |   test_cmd_trigger_vevents(dev_id, 3);
>        |   ^~~~~~~~~~~~~~~~~~~~~~~~
> 
> The issue can be reproduced, building the tests, with the command:
> make -C tools/testing/selftests TARGETS=iommu
> 
> Signed-off-by: Alessandro Zanni <alessandro.zanni87@gmail.com>
> ---
>   tools/testing/selftests/iommu/iommufd_utils.h | 8 +++-----
>   1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/testing/selftests/iommu/iommufd_utils.h b/tools/testing/selftests/iommu/iommufd_utils.h
> index 3c3e08b8c90e..772ca1db6e59 100644
> --- a/tools/testing/selftests/iommu/iommufd_utils.h
> +++ b/tools/testing/selftests/iommu/iommufd_utils.h
> @@ -1042,15 +1042,13 @@ static int _test_cmd_trigger_vevents(int fd, __u32 dev_id, __u32 nvevents)
>   			.dev_id = dev_id,
>   		},
>   	};
> -	int ret;
>   
>   	while (nvevents--) {
> -		ret = ioctl(fd, _IOMMU_TEST_CMD(IOMMU_TEST_OP_TRIGGER_VEVENT),
> -			    &trigger_vevent_cmd);
> -		if (ret < 0)
> +		if (!ioctl(fd, _IOMMU_TEST_CMD(IOMMU_TEST_OP_TRIGGER_VEVENT),
> +			    &trigger_vevent_cmd))
>   			return -1;
>   	}
> -	return ret;

Hmm. with this change -1 is returned instead of ret

> +	return 0;
>   }
>   
>   #define test_cmd_trigger_vevents(dev_id, nvevents) \

thanks,
-- Shuah


  reply	other threads:[~2025-10-07 21:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-24 16:57 [PATCH v2] Fix to avoid the usage of the `res` variable uninitialized in the following macro expansions Alessandro Zanni
2025-10-07 21:28 ` Shuah Khan [this message]
2025-10-08 13:24   ` Alessandro Zanni
2025-10-08 13:30     ` Jason Gunthorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dc360969-c1af-4b87-a259-cc265a8d553d@linuxfoundation.org \
    --to=skhan@linuxfoundation.org \
    --cc=alessandro.zanni87@gmail.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=kevin.tian@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox