[PATCH] selftests/proc: fix unused result warning during test compilation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 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





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux