From: Abhinav Jain <jain.abhinav177@gmail.com>
To: shuah@kernel.org, akpm@linux-foundation.org,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-kselftest@vger.kernel.org
Cc: skhan@linuxfoundation.org, jain.abhinav177@gmail.com,
javier.carrasco.cruz@gmail.com
Subject: [PATCH] selftests/proc: fix unused result warning during test compilation
Date: Tue, 25 Jun 2024 15:21:39 +0000 [thread overview]
Message-ID: <20240625152139.16412-1-jain.abhinav177@gmail.com> (raw)
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);
Signed-off-by: Abhinav Jain <jain.abhinav177@gmail.com>
---
tools/testing/selftests/proc/proc-empty-vm.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/proc/proc-empty-vm.c b/tools/testing/selftests/proc/proc-empty-vm.c
index 56198d4ca2bf..510ab4a5330a 100644
--- 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;
+ }
}
const char *p = buf;
--
2.34.1
next reply other threads:[~2024-06-25 15:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-25 15:21 Abhinav Jain [this message]
2024-06-25 18:05 ` [PATCH] selftests/proc: fix unused result warning during test compilation Andrew Morton
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=20240625152139.16412-1-jain.abhinav177@gmail.com \
--to=jain.abhinav177@gmail.com \
--cc=akpm@linux-foundation.org \
--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).