selftests/sched: fix warn_unused_result build warns
authorShuah Khan <skhan@linuxfoundation.org>
Mon, 13 Feb 2023 17:21:43 +0000 (10:21 -0700)
committerShuah Khan <skhan@linuxfoundation.org>
Mon, 13 Feb 2023 23:35:54 +0000 (16:35 -0700)
commita7151a8eaa292933cc934deb1dda0f5f51114c82
tree5d589172e7bc1b53ec85d22e00a93e66a5d7b846
parent6e81461b06b6a4a24bf97fca37d9b89f72ce8126
selftests/sched: fix warn_unused_result build warns

Fix the following warns by adding return check and error handling.

gcc -O2 -Wall -g -I./ -isystem .../tools/testing/selftests/../../../usr/include -Wl,-rpath=./      cs_prctl_test.c -lpthread -o .../tools/testing/selftests/sched/cs_prctl_test
cs_prctl_test.c: In function ‘create_processes’:
cs_prctl_test.c:187:17: warning: ignoring return value of ‘read’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  187 |                 read(proc[i].pfd[0], &proc[i].thr_tids, sizeof(int) * proc[i].num_threads);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cs_prctl_test.c: In function ‘child_func_process’:
cs_prctl_test.c:159:9: warning: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  159 |         write(ca->pfd[1], &ca->thr_tids, sizeof(int) * ca->num_threads);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/selftests/sched/cs_prctl_test.c