* [PATCH] selftests/powerpc: context_switch: Fix pthread errors
@ 2017-07-04 1:21 Cyril Bur
2017-10-19 4:48 ` Michael Ellerman
0 siblings, 1 reply; 2+ messages in thread
From: Cyril Bur @ 2017-07-04 1:21 UTC (permalink / raw)
To: linuxppc-dev
Turns out pthreads returns an errno and doesn't set errno. This doesn't
play well with perror().
Signed-off-by: Cyril Bur <cyrilbur@gmail.com>
---
.../selftests/powerpc/benchmarks/context_switch.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/powerpc/benchmarks/context_switch.c b/tools/testing/selftests/powerpc/benchmarks/context_switch.c
index 778f5fbfd784..7486e532d3e2 100644
--- a/tools/testing/selftests/powerpc/benchmarks/context_switch.c
+++ b/tools/testing/selftests/powerpc/benchmarks/context_switch.c
@@ -75,6 +75,7 @@ static void touch(void)
static void start_thread_on(void *(*fn)(void *), void *arg, unsigned long cpu)
{
+ int rc;
pthread_t tid;
cpu_set_t cpuset;
pthread_attr_t attr;
@@ -82,14 +83,23 @@ static void start_thread_on(void *(*fn)(void *), void *arg, unsigned long cpu)
CPU_ZERO(&cpuset);
CPU_SET(cpu, &cpuset);
- pthread_attr_init(&attr);
+ rc = pthread_attr_init(&attr);
+ if (rc) {
+ errno = rc;
+ perror("pthread_attr_init");
+ exit(1);
+ }
- if (pthread_attr_setaffinity_np(&attr, sizeof(cpu_set_t), &cpuset)) {
+ rc = pthread_attr_setaffinity_np(&attr, sizeof(cpu_set_t), &cpuset);
+ if (rc) {
+ errno = rc;
perror("pthread_attr_setaffinity_np");
exit(1);
}
- if (pthread_create(&tid, &attr, fn, arg)) {
+ rc = pthread_create(&tid, &attr, fn, arg);
+ if (rc) {
+ errno = rc;
perror("pthread_create");
exit(1);
}
--
2.13.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-10-19 4:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-04 1:21 [PATCH] selftests/powerpc: context_switch: Fix pthread errors Cyril Bur
2017-10-19 4:48 ` Michael Ellerman
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).