* [PATCH] selftests/proc: fix unused result warning during test compilation
@ 2024-06-25 15:21 Abhinav Jain
2024-06-25 18:05 ` Andrew Morton
0 siblings, 1 reply; 5+ messages in thread
From: Abhinav Jain @ 2024-06-25 15:21 UTC (permalink / raw)
To: shuah, akpm, linux-kernel, linux-fsdevel, linux-kselftest
Cc: skhan, jain.abhinav177, javier.carrasco.cruz
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] selftests/proc: fix unused result warning during test compilation
2024-06-25 15:21 [PATCH] selftests/proc: fix unused result warning during test compilation Abhinav Jain
@ 2024-06-25 18:05 ` Andrew Morton
2024-06-28 7:03 ` Abhinav Jain
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2024-06-25 18:05 UTC (permalink / raw)
To: Abhinav Jain
Cc: shuah, linux-kernel, linux-fsdevel, linux-kselftest, skhan,
javier.carrasco.cruz
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] selftests/proc: fix unused result warning during test compilation
2024-06-25 18:05 ` Andrew Morton
@ 2024-06-28 7:03 ` Abhinav Jain
2024-06-28 20:30 ` Andrew Morton
0 siblings, 1 reply; 5+ messages in thread
From: Abhinav Jain @ 2024-06-28 7:03 UTC (permalink / raw)
To: akpm
Cc: jain.abhinav177, javier.carrasco.cruz, linux-fsdevel,
linux-kernel, linux-kselftest, shuah, skhan
On Tue, 25 Jun 2024 11:05:26 -0700, Andrew Morton wrote:
> Thanks. There's a patch queued which simply deletes this code.
>
> https://lkml.kernel.org/r/20240603124220.33778-1-amer.shanawany@gmail.com
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] selftests/proc: fix unused result warning during test compilation
2024-06-28 7:03 ` Abhinav Jain
@ 2024-06-28 20:30 ` Andrew Morton
2024-06-29 5:08 ` Abhinav Jain
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2024-06-28 20:30 UTC (permalink / raw)
To: Abhinav Jain
Cc: javier.carrasco.cruz, linux-fsdevel, linux-kernel,
linux-kselftest, shuah, skhan
On Fri, 28 Jun 2024 07:03:38 +0000 Abhinav Jain <jain.abhinav177@gmail.com> wrote:
> On Tue, 25 Jun 2024 11:05:26 -0700, Andrew Morton wrote:
> > Thanks. There's a patch queued which simply deletes this code.
> >
> > https://lkml.kernel.org/r/20240603124220.33778-1-amer.shanawany@gmail.com
>
> 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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] selftests/proc: fix unused result warning during test compilation
2024-06-28 20:30 ` Andrew Morton
@ 2024-06-29 5:08 ` Abhinav Jain
0 siblings, 0 replies; 5+ messages in thread
From: Abhinav Jain @ 2024-06-29 5:08 UTC (permalink / raw)
To: akpm
Cc: jain.abhinav177, javier.carrasco.cruz, linux-fsdevel,
linux-kernel, linux-kselftest, shuah, skhan
On Fri, 28 Jun 2024 13:30:14 -0700, Andrew Morton wrote:
> 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/20240629050449.990451-1-jain.abhinav177@gmail.com/
Please review. Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-06-29 5:08 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-25 15:21 [PATCH] selftests/proc: fix unused result warning during test compilation Abhinav Jain
2024-06-25 18:05 ` Andrew Morton
2024-06-28 7:03 ` Abhinav Jain
2024-06-28 20:30 ` Andrew Morton
2024-06-29 5:08 ` Abhinav Jain
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).