diff options
author | Hou Tao <[email protected]> | 2023-06-13 16:09:18 +0800 |
---|---|---|
committer | Alexei Starovoitov <[email protected]> | 2023-06-19 13:26:43 -0700 |
commit | ea400d13fc92ec66578b068e661a162e01d4b641 (patch) | |
tree | 3faf137f1dd759aba5b9aefd512edd2adc100faa | |
parent | 8ad663d3dfac95cbcc4121d0655bd18ad9de826f (diff) |
selftests/bpf: Output the correct error code for pthread APIs
The return value of pthread API is the error code when the called
API fails, so output the return value instead of errno.
Signed-off-by: Hou Tao <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Alexei Starovoitov <[email protected]>
-rw-r--r-- | tools/testing/selftests/bpf/bench.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/tools/testing/selftests/bpf/bench.c b/tools/testing/selftests/bpf/bench.c index d9c080ac1796..0b5d2b5303c9 100644 --- a/tools/testing/selftests/bpf/bench.c +++ b/tools/testing/selftests/bpf/bench.c @@ -441,12 +441,14 @@ static void setup_timer() static void set_thread_affinity(pthread_t thread, int cpu) { cpu_set_t cpuset; + int err; CPU_ZERO(&cpuset); CPU_SET(cpu, &cpuset); - if (pthread_setaffinity_np(thread, sizeof(cpuset), &cpuset)) { + err = pthread_setaffinity_np(thread, sizeof(cpuset), &cpuset); + if (err) { fprintf(stderr, "setting affinity to CPU #%d failed: %d\n", - cpu, errno); + cpu, -err); exit(1); } } @@ -605,7 +607,7 @@ static void setup_benchmark(void) bench->consumer_thread, (void *)(long)i); if (err) { fprintf(stderr, "failed to create consumer thread #%d: %d\n", - i, -errno); + i, -err); exit(1); } if (env.affinity) @@ -624,7 +626,7 @@ static void setup_benchmark(void) bench->producer_thread, (void *)(long)i); if (err) { fprintf(stderr, "failed to create producer thread #%d: %d\n", - i, -errno); + i, -err); exit(1); } if (env.affinity) |