[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <3a279a31-7a3b-fed9-e50f-b0d86f4de4f6@linuxfoundation.org>
Date: Mon, 18 Sep 2023 11:14:11 -0600
From: Shuah Khan <skhan@...uxfoundation.org>
To: Javier Carrasco <javier.carrasco.cruz@...il.com>,
Shuah Khan <shuah@...nel.org>
Cc: linux-kselftest@...r.kernel.org, linux-kernel@...r.kernel.org,
Shuah Khan <skhan@...uxfoundation.org>
Subject: Re: [PATCH] selftests: uevent filtering: fix return on error in
uevent_listener
On 9/16/23 10:11, Javier Carrasco wrote:
> Assign the error value to the real returned variable fret. The ret
> variable is used to check function return values and assigning values to
> it on error has no effect as it is an unused value.
>
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@...il.com>
> ---
> tools/testing/selftests/uevent/uevent_filtering.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/uevent/uevent_filtering.c b/tools/testing/selftests/uevent/uevent_filtering.c
> index 5cebfb356345..e191b6d69f8c 100644
> --- a/tools/testing/selftests/uevent/uevent_filtering.c
> +++ b/tools/testing/selftests/uevent/uevent_filtering.c
> @@ -158,7 +158,7 @@ static int uevent_listener(unsigned long post_flags, bool expect_uevent,
> r = recvmsg(sk_fd, &hdr, 0);
> if (r <= 0) {
> fprintf(stderr, "%s - Failed to receive uevent\n", strerror(errno));
> - ret = -1;
> + fret = -1;
> break;
> }
>
> @@ -172,7 +172,7 @@ static int uevent_listener(unsigned long post_flags, bool expect_uevent,
>
> if (!expect_uevent) {
> fprintf(stderr, "Received unexpected uevent:\n");
> - ret = -1;
> + fret = -1;
> }
>
> if (TH_LOG_ENABLED) {
>
Thank you for the find. Please simplify these leg and use just one
variable for failures, ret or fret and not both to avoid future
coding errors like this one you are fixing.
thanks,
-- Shuah
Powered by blists - more mailing lists