[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20240629050449.990451-1-jain.abhinav177@gmail.com>
Date: Sat, 29 Jun 2024 05:04:49 +0000
From: Abhinav Jain <jain.abhinav177@...il.com>
To: shuah@...nel.org,
akpm@...ux-foundation.org,
linux-kernel@...r.kernel.org,
linux-fsdevel@...r.kernel.org,
linux-kselftest@...r.kernel.org
Cc: skhan@...uxfoundation.org,
jain.abhinav177@...il.com,
javier.carrasco.cruz@...il.com
Subject: [PATCH v2] selftests/proc: fix unused result warning during test compilation
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@...il.com>
---
Changes since v1:
- Remove the redundant if(0) block as per the feedback
- Patch v1:
https://lore.kernel.org/all/20240625152139.16412-1-jain.abhinav177@gmail.com/
---
tools/testing/selftests/proc/proc-empty-vm.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/proc/proc-empty-vm.c b/tools/testing/selftests/proc/proc-empty-vm.c
index 56198d4ca2bf..123c622cd816 100644
--- a/tools/testing/selftests/proc/proc-empty-vm.c
+++ b/tools/testing/selftests/proc/proc-empty-vm.c
@@ -381,8 +381,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
Powered by blists - more mailing lists