Remove dead NULL checks from pthread code.

GCC is removing these checks anyway because it knows the arguments
must be non-null, so leaving this code around is just confusing.

We know from experience that people were shipping code with locking
bugs because they weren't checking for error returns. Failing hard
like glibc does seems the better choice. (And it's what the checked
in code was already doing; this patch doesn't change that. It just
makes it more obvious that that's what's going on.)

Change-Id: I167c6d7c0a296822baf0cb9b43b97821eba7ab35
This commit is contained in:
Elliott Hughes
2014-03-04 10:55:39 -08:00
parent a0bf9bdea2
commit 39b644a0e2
4 changed files with 17 additions and 88 deletions

View File

@@ -96,9 +96,6 @@ int pthread_condattr_setclock(pthread_condattr_t* attr, clockid_t clock) {
}
int pthread_condattr_destroy(pthread_condattr_t* attr) {
if (attr == NULL) {
return EINVAL;
}
*attr = 0xdeada11d;
return 0;
}
@@ -112,10 +109,6 @@ int pthread_condattr_destroy(pthread_condattr_t* attr) {
// XXX then the signal will be lost.
int pthread_cond_init(pthread_cond_t* cond, const pthread_condattr_t* attr) {
if (cond == NULL) {
return EINVAL;
}
if (attr != NULL) {
cond->value = (*attr & COND_FLAGS_MASK);
} else {
@@ -126,10 +119,6 @@ int pthread_cond_init(pthread_cond_t* cond, const pthread_condattr_t* attr) {
}
int pthread_cond_destroy(pthread_cond_t* cond) {
if (cond == NULL) {
return EINVAL;
}
cond->value = 0xdeadc04d;
return 0;
}
@@ -138,10 +127,6 @@ int pthread_cond_destroy(pthread_cond_t* cond) {
// pthread_cond_signal to atomically decrement the counter
// then wake up 'counter' threads.
static int __pthread_cond_pulse(pthread_cond_t* cond, int counter) {
if (__predict_false(cond == NULL)) {
return EINVAL;
}
int flags = (cond->value & COND_FLAGS_MASK);
while (true) {
int old_value = cond->value;