selftests/proc: fix unused result warning during test compilation
Subsystems (3)
PATCH 1/1 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);
--- tools/testing/selftests/proc/proc-empty-vm.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
tools/testing/selftests/proc/proc-empty-vm.c +6 -1
@@ -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;
Signature · 1 line
2.34.1
Quoted 14 lines · On Tue, 25 Jun 2024 15:21:39 +0000 Abhinav Jain <[email protected]>…
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);...
tools/testing/selftests/proc/proc-empty-vm.c +0
-0@@ -382,7 +382,12 @@ static int test_proc_pid_statm(pid_t pid)assert (rv >=0 );
tools/testing/selftests/proc/proc-empty-vm.c static int test_proc_pid_statm(pid_t pid) · line 391
Quoted 10 lines
tools/testing/selftests/proc/proc-empty-vm.c +6
-1assert (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.
Quoted 3 lines · Andrew Morton
Thanks. There's a patch queued which simply deletes this code.
Thank you for sharing the queued patch Andrew.
There has been no update/revert on it, may I know what would be the next step here? After reading the patch above, I believe my change is "more" right. Is that correct?
Thanks and Regards
- Abhinav
Quoted 9 lines · On Fri, 28 Jun 2024 07:03:38 +0000 Abhinav Jain <[email protected]>…
Quoted 3 lines · Andrew Morton
Thanks. There's a patch queued which simply deletes this code.
Thank you for sharing the queued patch Andrew.
There has been no update/revert on it, may I know what would be the next step here? After reading the patch above, I believe my change is "more" right. Is that correct?
Well, it's all inside `if (0)', so just remove it.
Quoted 1 line · Andrew Morton
Well, it's all inside `if (0)', so just remove it.
Removed and shared v2 version of the patch here:
https://lore.kernel.org/all/[email protected]/
Please review. Thanks.