diff options
author | John Kacur <jkacur@redhat.com> | 2012-03-21 22:29:43 +0100 |
---|---|---|
committer | John Kacur <jkacur@redhat.com> | 2012-03-23 02:15:19 +0100 |
commit | 9eef81de2f8a0b16e183070a1ff7d1580d650fb3 (patch) | |
tree | 02294282e3f1fd0ac0e11ab3d733f626261cd9c6 | |
parent | b52b383192e7a38e129ac0e10a361214721fcb83 (diff) | |
download | cyclictest-9eef81de2f8a0b16e183070a1ff7d1580d650fb3.tar.gz |
pi_stress: Check the status of sched_getaffinity
Check the status of sched_getaffinity and exit upon error.
CPU_ISSET only checks whether a cpu is in a mask, and not whether the
mask is valid. Checking the status ensures we aren't working with garbage
values.
This also removes the warning from gcc about the status variable being unused
as reported by Darren Hart.
Reported-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
-rw-r--r-- | src/pi_tests/pi_stress.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/pi_tests/pi_stress.c b/src/pi_tests/pi_stress.c index 0940567..e273d62 100644 --- a/src/pi_tests/pi_stress.c +++ b/src/pi_tests/pi_stress.c @@ -597,9 +597,17 @@ void *reporter(void *arg) int verify_cpu(int cpu) { int status; + int err; cpu_set_t mask; + CPU_ZERO(&mask); + status = sched_getaffinity(0, sizeof(cpu_set_t), &mask); + if (status == -1) { + err = errno; + fprintf(stderr, "sched_getaffinity %s\n", strerror(err)); + exit(-1); + } if (CPU_ISSET(cpu, &mask)) return SUCCESS; |