public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Shuah Khan <skhan@linuxfoundation.org>
To: angquan yu <angquan21@gmail.com>
Cc: shuah@kernel.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-kernel-mentees@lists.linuxfoundation.org,
	Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH] selftests:proc: Resolve 'Unused Result' Warning from proc-empty-vm.c
Date: Thu, 30 Nov 2023 13:25:37 -0700	[thread overview]
Message-ID: <2845b899-efd8-49db-8ea6-18834e97071e@linuxfoundation.org> (raw)
In-Reply-To: <20231129034556.5719-1-angquan21@gmail.com>

On 11/28/23 20:45, angquan yu wrote:
> From: angquan yu <angquan21@gmail.com>
> 
> In tools/testing/selftests/proc/proc-empty->because the return value
> of a write call was being ignored. This call was partof a conditional
> debugging block (if (0) { ... }), which meant it would neveractually
> execute.
> 
> This patch removes the unused debug write call. This cleanup resolves
> the compi>warning about ignoring the result of write declared with
> the warn_unused_resultattribute.
> 
> Removing this code also improves the clarity and maintainability of
> the function, as it eliminates a non-functional block of code.
> 
> This is original warning: proc-empty-vm.c: In function
> ‘test_proc_pid_statm’ :proc-empty-vm.c:385:17:
> warning: ignoring return value of ‘write’
> declared with>385 |                 write(1, buf, rv);|
> 
> Signed-off-by: angquan yu <angquan21@gmail.com>
> ---
>   tools/testing/selftests/proc/proc-empty-vm.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/tools/testing/selftests/proc/proc-empty-vm.c b/tools/testing/selftests/proc/proc-empty-vm.c
> index 5e7020630..d231e61e4 100644
> --- a/tools/testing/selftests/proc/proc-empty-vm.c
> +++ b/tools/testing/selftests/proc/proc-empty-vm.c
> @@ -383,8 +383,10 @@ static int test_proc_pid_statm(pid_t pid)
>   	assert(rv <= sizeof(buf));
>   	if (0) {
>   		ssize_t written = write(1, buf, rv);
> +
>   		if (written == -1) {
>   			perror("write failed to /proc/${pid}");
> +			return EXIT_FAILURE;
>   		}
>   	}
>   

Hmm. Is this patch based on Linux 6.7-rc3? The code doesn't
match?

thanks,
-- Shuah

      reply	other threads:[~2023-11-30 20:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-29  3:45 [PATCH] selftests:proc: Resolve 'Unused Result' Warning from proc-empty-vm.c angquan yu
2023-11-30 20:25 ` Shuah Khan [this message]

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=2845b899-efd8-49db-8ea6-18834e97071e@linuxfoundation.org \
    --to=skhan@linuxfoundation.org \
    --cc=angquan21@gmail.com \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --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