linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests: proc: remove unreached code and fix build warning
       [not found] <202404010211.ygidvMwa-lkp@intel.com>
@ 2024-06-03 12:42 ` Amer Al Shanawany
  2024-06-03 14:24   ` Alexey Dobriyan
  0 siblings, 1 reply; 5+ messages in thread
From: Amer Al Shanawany @ 2024-06-03 12:42 UTC (permalink / raw)
  To: Shuah Khan, Andrew Morton, Alexey Dobriyan,
	Swarup Laxman Kotiaklapudi, Hugh Dickins, linux-kernel,
	linux-fsdevel, linux-kselftest
  Cc: Javier Carrasco, kernel test robot, Amer Al Shanawany

fix the following warning:
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);
      |                 ^~~~~~~~~~~~~~~~~

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/r/202404010211.ygidvMwa-lkp@intel.com/
Signed-off-by: Amer Al Shanawany <amer.shanawany@gmail.com>
---
 tools/testing/selftests/proc/proc-empty-vm.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/tools/testing/selftests/proc/proc-empty-vm.c b/tools/testing/selftests/proc/proc-empty-vm.c
index 56198d4ca2bf..b3f898aab4ab 100644
--- a/tools/testing/selftests/proc/proc-empty-vm.c
+++ b/tools/testing/selftests/proc/proc-empty-vm.c
@@ -381,9 +381,6 @@ static int test_proc_pid_statm(pid_t pid)
 
 	assert(rv >= 0);
 	assert(rv <= sizeof(buf));
-	if (0) {
-		write(1, buf, rv);
-	}
 
 	const char *p = buf;
 	const char *const end = p + rv;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] selftests: proc: remove unreached code and fix build warning
  2024-06-03 12:42 ` [PATCH] selftests: proc: remove unreached code and fix build warning Amer Al Shanawany
@ 2024-06-03 14:24   ` Alexey Dobriyan
  2024-06-05  3:25     ` Andrew Morton
  0 siblings, 1 reply; 5+ messages in thread
From: Alexey Dobriyan @ 2024-06-03 14:24 UTC (permalink / raw)
  To: Amer Al Shanawany
  Cc: Shuah Khan, Andrew Morton, Swarup Laxman Kotiaklapudi,
	Hugh Dickins, linux-kernel, linux-fsdevel, linux-kselftest,
	Javier Carrasco, kernel test robot

On Mon, Jun 03, 2024 at 02:42:20PM +0200, Amer Al Shanawany wrote:
> fix the following warning:
> proc-empty-vm.c:385:17: warning: ignoring return value of ‘write’

> --- a/tools/testing/selftests/proc/proc-empty-vm.c
> +++ b/tools/testing/selftests/proc/proc-empty-vm.c
> @@ -381,9 +381,6 @@ static int test_proc_pid_statm(pid_t pid)

> -	if (0) {
> -		write(1, buf, rv);
> -	}

no thanks

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] selftests: proc: remove unreached code and fix build warning
  2024-06-03 14:24   ` Alexey Dobriyan
@ 2024-06-05  3:25     ` Andrew Morton
  2024-06-07 15:25       ` Alexey Dobriyan
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2024-06-05  3:25 UTC (permalink / raw)
  To: Alexey Dobriyan
  Cc: Amer Al Shanawany, Shuah Khan, Swarup Laxman Kotiaklapudi,
	Hugh Dickins, linux-kernel, linux-fsdevel, linux-kselftest,
	Javier Carrasco, kernel test robot

On Mon, 3 Jun 2024 17:24:47 +0300 Alexey Dobriyan <adobriyan@gmail.com> wrote:

> On Mon, Jun 03, 2024 at 02:42:20PM +0200, Amer Al Shanawany wrote:
> > fix the following warning:
> > proc-empty-vm.c:385:17: warning: ignoring return value of ‘write’
> 
> > --- a/tools/testing/selftests/proc/proc-empty-vm.c
> > +++ b/tools/testing/selftests/proc/proc-empty-vm.c
> > @@ -381,9 +381,6 @@ static int test_proc_pid_statm(pid_t pid)
> 
> > -	if (0) {
> > -		write(1, buf, rv);
> > -	}
> 
> no thanks

Why not?

Why does that code exist anyway?  It at least needs a comment.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] selftests: proc: remove unreached code and fix build warning
  2024-06-05  3:25     ` Andrew Morton
@ 2024-06-07 15:25       ` Alexey Dobriyan
  2024-06-11 15:04         ` Shuah Khan
  0 siblings, 1 reply; 5+ messages in thread
From: Alexey Dobriyan @ 2024-06-07 15:25 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Amer Al Shanawany, Shuah Khan, Swarup Laxman Kotiaklapudi,
	Hugh Dickins, linux-kernel, linux-fsdevel, linux-kselftest,
	Javier Carrasco, kernel test robot

On Tue, Jun 04, 2024 at 08:25:31PM -0700, Andrew Morton wrote:
> On Mon, 3 Jun 2024 17:24:47 +0300 Alexey Dobriyan <adobriyan@gmail.com> wrote:
> 
> > On Mon, Jun 03, 2024 at 02:42:20PM +0200, Amer Al Shanawany wrote:
> > > fix the following warning:
> > > proc-empty-vm.c:385:17: warning: ignoring return value of ‘write’
> > 
> > > --- a/tools/testing/selftests/proc/proc-empty-vm.c
> > > +++ b/tools/testing/selftests/proc/proc-empty-vm.c
> > > @@ -381,9 +381,6 @@ static int test_proc_pid_statm(pid_t pid)
> > 
> > > -	if (0) {
> > > -		write(1, buf, rv);
> > > -	}
> > 
> > no thanks
> 
> Why not?
> 
> Why does that code exist anyway?  It at least needs a comment.

OK, whatever.

If test fails, it better record buggy output somewhere (to coredump or to terminal).

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] selftests: proc: remove unreached code and fix build warning
  2024-06-07 15:25       ` Alexey Dobriyan
@ 2024-06-11 15:04         ` Shuah Khan
  0 siblings, 0 replies; 5+ messages in thread
From: Shuah Khan @ 2024-06-11 15:04 UTC (permalink / raw)
  To: Alexey Dobriyan, Andrew Morton
  Cc: Amer Al Shanawany, Shuah Khan, Swarup Laxman Kotiaklapudi,
	Hugh Dickins, linux-kernel, linux-fsdevel, linux-kselftest,
	Javier Carrasco, kernel test robot, Shuah Khan

On 6/7/24 09:25, Alexey Dobriyan wrote:
> On Tue, Jun 04, 2024 at 08:25:31PM -0700, Andrew Morton wrote:
>> On Mon, 3 Jun 2024 17:24:47 +0300 Alexey Dobriyan <adobriyan@gmail.com> wrote:
>>
>>> On Mon, Jun 03, 2024 at 02:42:20PM +0200, Amer Al Shanawany wrote:
>>>> fix the following warning:
>>>> proc-empty-vm.c:385:17: warning: ignoring return value of ‘write’
>>>
>>>> --- a/tools/testing/selftests/proc/proc-empty-vm.c
>>>> +++ b/tools/testing/selftests/proc/proc-empty-vm.c
>>>> @@ -381,9 +381,6 @@ static int test_proc_pid_statm(pid_t pid)
>>>
>>>> -	if (0) {
>>>> -		write(1, buf, rv);
>>>> -	}
>>>
>>> no thanks
>>
>> Why not?
>>
>> Why does that code exist anyway?  It at least needs a comment.
> 
> OK, whatever.
> 
> If test fails, it better record buggy output somewhere (to coredump or to terminal).

+1 on reporting results - the best way to do this is to add a meaningful message
for users to understand what went wrong.

Please suggest how you would like this warning addressed and report the error.

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-06-11 15:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <202404010211.ygidvMwa-lkp@intel.com>
2024-06-03 12:42 ` [PATCH] selftests: proc: remove unreached code and fix build warning Amer Al Shanawany
2024-06-03 14:24   ` Alexey Dobriyan
2024-06-05  3:25     ` Andrew Morton
2024-06-07 15:25       ` Alexey Dobriyan
2024-06-11 15:04         ` Shuah Khan

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).