diff options
author | Andreas Kling <kling@serenityos.org> | 2020-11-26 11:51:26 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-11-26 19:33:44 +0100 |
commit | ffa44050835fd75a4b6fbf3356034b07f0456b83 (patch) | |
tree | 97301cda129bbceee64ddab799cb0efc2c3821c5 | |
parent | a5e560ee49621ba025933a1af576ded34a975bfc (diff) | |
download | serenity-ffa44050835fd75a4b6fbf3356034b07f0456b83.zip |
LibPthread: Fix broken EINVAL check in pthread_attr_setdetachstate()
Also fix up some misleading error messages in the 'tt' test program.
-rw-r--r-- | Libraries/LibPthread/pthread.cpp | 2 | ||||
-rw-r--r-- | Userland/tt.cpp | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/Libraries/LibPthread/pthread.cpp b/Libraries/LibPthread/pthread.cpp index 4c69f7b6aa..75109fc928 100644 --- a/Libraries/LibPthread/pthread.cpp +++ b/Libraries/LibPthread/pthread.cpp @@ -278,7 +278,7 @@ int pthread_attr_setdetachstate(pthread_attr_t* attributes, int detach_state) if (!attributes_impl) return EINVAL; - if ((PTHREAD_CREATE_JOINABLE != detach_state) || PTHREAD_CREATE_DETACHED != detach_state) + if (detach_state != PTHREAD_CREATE_JOINABLE && detach_state != PTHREAD_CREATE_DETACHED) return EINVAL; attributes_impl->m_detach_state = detach_state; diff --git a/Userland/tt.cpp b/Userland/tt.cpp index 3e7b3ccd71..d1a3514458 100644 --- a/Userland/tt.cpp +++ b/Userland/tt.cpp @@ -130,14 +130,14 @@ int detached_test() pthread_attr_t attributes; int rc = pthread_attr_init(&attributes); if (rc != 0) { - printf("pthread_attr_setdetachstate: %s\n", strerror(rc)); + printf("pthread_attr_init: %s\n", strerror(rc)); return 1; } int detach_state = 99; // clearly invalid rc = pthread_attr_getdetachstate(&attributes, &detach_state); if (rc != 0) { - printf("pthread_attr_setdetachstate: %s\n", strerror(rc)); + printf("pthread_attr_getdetachstate: %s\n", strerror(rc)); return 2; } printf("Default detach state: %s\n", detach_state == PTHREAD_CREATE_JOINABLE ? "joinable" : "detached"); @@ -181,7 +181,7 @@ int detached_test() rc = pthread_attr_destroy(&attributes); if (rc != 0) { - printf("pthread_attr_setdetachstate: %s\n", strerror(rc)); + printf("pthread_attr_destroy: %s\n", strerror(rc)); return 7; } |