public inbox for sched-ext@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH 0/1] selftests/sched_ext: Fix unused-result warning for read()
@ 2026-02-21 12:56 Cheng-Yang Chou
  2026-02-21 12:56 ` [PATCH 1/1] " Cheng-Yang Chou
  2026-02-23 17:57 ` [PATCH 0/1] " Tejun Heo
  0 siblings, 2 replies; 5+ messages in thread
From: Cheng-Yang Chou @ 2026-02-21 12:56 UTC (permalink / raw)
  To: sched-ext; +Cc: tj, void, arighi, changwoo, jserv, yphbchou0911

The build fails under -Werror because read() ignores its return
value, triggering a warn_unused_result compiler error:

init_enable_count.c: In function ‘run_test’:
init_enable_count.c:60:25: error: ignoring return value of ‘read’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result]
   60 |                         read(pipe_fds[0], &buf, 1);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as error

Check the return value of read() to satisfy the compiler and
catch unexpected pipe failures.

Thanks,
cheng-yang

---

Cheng-Yang Chou (1):
  selftests/sched_ext: Fix unused-result warning for read()

 tools/testing/selftests/sched_ext/init_enable_count.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

-- 
2.48.1


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

* [PATCH 1/1] selftests/sched_ext: Fix unused-result warning for read()
  2026-02-21 12:56 [PATCH 0/1] selftests/sched_ext: Fix unused-result warning for read() Cheng-Yang Chou
@ 2026-02-21 12:56 ` Cheng-Yang Chou
  2026-02-21 19:37   ` Andrea Righi
  2026-02-23 17:57 ` [PATCH 0/1] " Tejun Heo
  1 sibling, 1 reply; 5+ messages in thread
From: Cheng-Yang Chou @ 2026-02-21 12:56 UTC (permalink / raw)
  To: sched-ext; +Cc: tj, void, arighi, changwoo, jserv, yphbchou0911

The read() call in run_test() triggers a warn_unused_result compiler
warning, which breaks the build under -Werror.

Check the return value of read() and exit the child process upon
failure to satisfy the compiler and prevent unexpected pipe errors.

Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
---
 tools/testing/selftests/sched_ext/init_enable_count.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/sched_ext/init_enable_count.c b/tools/testing/selftests/sched_ext/init_enable_count.c
index 82c71653977b..44577e30e764 100644
--- a/tools/testing/selftests/sched_ext/init_enable_count.c
+++ b/tools/testing/selftests/sched_ext/init_enable_count.c
@@ -57,7 +57,8 @@ static enum scx_test_status run_test(bool global)
 			char buf;
 
 			close(pipe_fds[1]);
-			read(pipe_fds[0], &buf, 1);
+			if (read(pipe_fds[0], &buf, 1) < 0)
+				exit(1);
 			close(pipe_fds[0]);
 			exit(0);
 		}
-- 
2.48.1


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

* Re: [PATCH 1/1] selftests/sched_ext: Fix unused-result warning for read()
  2026-02-21 12:56 ` [PATCH 1/1] " Cheng-Yang Chou
@ 2026-02-21 19:37   ` Andrea Righi
  2026-02-22  8:25     ` Cheng-Yang Chou
  0 siblings, 1 reply; 5+ messages in thread
From: Andrea Righi @ 2026-02-21 19:37 UTC (permalink / raw)
  To: Cheng-Yang Chou; +Cc: sched-ext, tj, void, changwoo, jserv

On Sat, Feb 21, 2026 at 08:56:14PM +0800, Cheng-Yang Chou wrote:
> The read() call in run_test() triggers a warn_unused_result compiler
> warning, which breaks the build under -Werror.
> 
> Check the return value of read() and exit the child process upon
> failure to satisfy the compiler and prevent unexpected pipe errors.

To be really picky I'd rephrase this part as:

Check the return value of read() and exit the child process on failure to
satisfy the compiler and handle pipe read errors.

"Prevent" suggests avoiding the error, which isn't what the patch does.
But it also looks good as it is.

Reviewed-by: Andrea Righi <arighi@nvidia.com>

Thanks,
-Andrea

> 
> Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
> ---
>  tools/testing/selftests/sched_ext/init_enable_count.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/sched_ext/init_enable_count.c b/tools/testing/selftests/sched_ext/init_enable_count.c
> index 82c71653977b..44577e30e764 100644
> --- a/tools/testing/selftests/sched_ext/init_enable_count.c
> +++ b/tools/testing/selftests/sched_ext/init_enable_count.c
> @@ -57,7 +57,8 @@ static enum scx_test_status run_test(bool global)
>  			char buf;
>  
>  			close(pipe_fds[1]);
> -			read(pipe_fds[0], &buf, 1);
> +			if (read(pipe_fds[0], &buf, 1) < 0)
> +				exit(1);
>  			close(pipe_fds[0]);
>  			exit(0);
>  		}
> -- 
> 2.48.1
> 

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

* [PATCH 1/1] selftests/sched_ext: Fix unused-result warning for read()
  2026-02-21 19:37   ` Andrea Righi
@ 2026-02-22  8:25     ` Cheng-Yang Chou
  0 siblings, 0 replies; 5+ messages in thread
From: Cheng-Yang Chou @ 2026-02-22  8:25 UTC (permalink / raw)
  To: arighi; +Cc: changwoo, jserv, sched-ext, tj, void, yphbchou0911

The read() call in run_test() triggers a warn_unused_result compiler
warning, which breaks the build under -Werror.

Check the return value of read() and exit the child process on failure to
satisfy the compiler and handle pipe read errors.

Reviewed-by: Andrea Righi <arighi@nvidia.com>
Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
---
v2: - Clarify error handling in commit message (Andrea Righi)

 tools/testing/selftests/sched_ext/init_enable_count.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/sched_ext/init_enable_count.c b/tools/testing/selftests/sched_ext/init_enable_count.c
index 82c71653977b..44577e30e764 100644
--- a/tools/testing/selftests/sched_ext/init_enable_count.c
+++ b/tools/testing/selftests/sched_ext/init_enable_count.c
@@ -57,7 +57,8 @@ static enum scx_test_status run_test(bool global)
 			char buf;
 
 			close(pipe_fds[1]);
-			read(pipe_fds[0], &buf, 1);
+			if (read(pipe_fds[0], &buf, 1) < 0)
+				exit(1);
 			close(pipe_fds[0]);
 			exit(0);
 		}
-- 
2.48.1


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

* Re: [PATCH 0/1] selftests/sched_ext: Fix unused-result warning for read()
  2026-02-21 12:56 [PATCH 0/1] selftests/sched_ext: Fix unused-result warning for read() Cheng-Yang Chou
  2026-02-21 12:56 ` [PATCH 1/1] " Cheng-Yang Chou
@ 2026-02-23 17:57 ` Tejun Heo
  1 sibling, 0 replies; 5+ messages in thread
From: Tejun Heo @ 2026-02-23 17:57 UTC (permalink / raw)
  To: Cheng-Yang Chou; +Cc: sched-ext, void, arighi, changwoo, jserv

> Cheng-Yang Chou (1):
>   selftests/sched_ext: Fix unused-result warning for read()

Applied to sched_ext/for-7.0-fixes.

Thanks.

--
tejun

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

end of thread, other threads:[~2026-02-23 17:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-21 12:56 [PATCH 0/1] selftests/sched_ext: Fix unused-result warning for read() Cheng-Yang Chou
2026-02-21 12:56 ` [PATCH 1/1] " Cheng-Yang Chou
2026-02-21 19:37   ` Andrea Righi
2026-02-22  8:25     ` Cheng-Yang Chou
2026-02-23 17:57 ` [PATCH 0/1] " Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox