From: Andrew Morton <akpm@linux-foundation.org>
To: Abhinav Jain <jain.abhinav177@gmail.com>
Cc: shuah@kernel.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linux-kselftest@vger.kernel.org,
skhan@linuxfoundation.org, javier.carrasco.cruz@gmail.com
Subject: Re: [PATCH] selftests/proc: fix unused result warning during test compilation
Date: Tue, 25 Jun 2024 11:05:26 -0700 [thread overview]
Message-ID: <20240625110526.d443fe6d3feb51a50aebf849@linux-foundation.org> (raw)
In-Reply-To: <20240625152139.16412-1-jain.abhinav177@gmail.com>
On Tue, 25 Jun 2024 15:21:39 +0000 Abhinav Jain <jain.abhinav177@gmail.com> wrote:
> Check the return value from write function to get rid of the warning
> during test compilation, shared below.
> Tested by compiling after the change, the warning disappears.
>
> proc-empty-vm.c:385:17: warning: ignoring return value of ‘write’
> declared with attribute ‘warn_unused_result’ [-Wunused-result]
> 385 | write(1, buf, rv);
>
> ...
>
> --- a/tools/testing/selftests/proc/proc-empty-vm.c
> +++ b/tools/testing/selftests/proc/proc-empty-vm.c
> @@ -382,7 +382,12 @@ static int test_proc_pid_statm(pid_t pid)
> assert(rv >= 0);
> assert(rv <= sizeof(buf));
> if (0) {
> - write(1, buf, rv);
> + ssize_t bytes_written = write(1, buf, rv);
> +
> + if (bytes_written != rv) {
> + perror("write");
> + return EXIT_FAILURE;
> + }
> }
Thanks. There's a patch queued which simply deletes this code.
https://lkml.kernel.org/r/20240603124220.33778-1-amer.shanawany@gmail.com
next prev parent reply other threads:[~2024-06-25 18:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-25 15:21 [PATCH] selftests/proc: fix unused result warning during test compilation Abhinav Jain
2024-06-25 18:05 ` Andrew Morton [this message]
2024-06-28 7:03 ` Abhinav Jain
2024-06-28 20:30 ` Andrew Morton
2024-06-29 5:08 ` Abhinav Jain
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=20240625110526.d443fe6d3feb51a50aebf849@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=jain.abhinav177@gmail.com \
--cc=javier.carrasco.cruz@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=skhan@linuxfoundation.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;
as well as URLs for NNTP newsgroup(s).