mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 17:17:42 +00:00
LibPthread: Fix broken EINVAL check in pthread_attr_setdetachstate()
Also fix up some misleading error messages in the 'tt' test program.
This commit is contained in:
parent
a5e560ee49
commit
ffa4405083
2 changed files with 4 additions and 4 deletions
|
@ -278,7 +278,7 @@ int pthread_attr_setdetachstate(pthread_attr_t* attributes, int detach_state)
|
||||||
if (!attributes_impl)
|
if (!attributes_impl)
|
||||||
return EINVAL;
|
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;
|
return EINVAL;
|
||||||
|
|
||||||
attributes_impl->m_detach_state = detach_state;
|
attributes_impl->m_detach_state = detach_state;
|
||||||
|
|
|
@ -130,14 +130,14 @@ int detached_test()
|
||||||
pthread_attr_t attributes;
|
pthread_attr_t attributes;
|
||||||
int rc = pthread_attr_init(&attributes);
|
int rc = pthread_attr_init(&attributes);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
printf("pthread_attr_setdetachstate: %s\n", strerror(rc));
|
printf("pthread_attr_init: %s\n", strerror(rc));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int detach_state = 99; // clearly invalid
|
int detach_state = 99; // clearly invalid
|
||||||
rc = pthread_attr_getdetachstate(&attributes, &detach_state);
|
rc = pthread_attr_getdetachstate(&attributes, &detach_state);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
printf("pthread_attr_setdetachstate: %s\n", strerror(rc));
|
printf("pthread_attr_getdetachstate: %s\n", strerror(rc));
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
printf("Default detach state: %s\n", detach_state == PTHREAD_CREATE_JOINABLE ? "joinable" : "detached");
|
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);
|
rc = pthread_attr_destroy(&attributes);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
printf("pthread_attr_setdetachstate: %s\n", strerror(rc));
|
printf("pthread_attr_destroy: %s\n", strerror(rc));
|
||||||
return 7;
|
return 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue