Make pthread_*_destroy() more standards compliant
authorMichael Neumann <mneumann@ntecs.de>
Thu, 8 Jan 2015 23:40:06 +0000 (00:40 +0100)
committerMichael Neumann <mneumann@ntecs.de>
Thu, 8 Jan 2015 23:40:06 +0000 (00:40 +0100)
commit146da5fcd4be3d6b3e74514ab38418637b600540
tree2db9ca3dad92a7af272ab175236d51354cd14d91
parent536a8300c32bdf0b5bba36cfda13cadeac20ce13
Make pthread_*_destroy() more standards compliant

Function pthread_{mutex,cond,rwlock}_destroy() returned EINVAL when the
mutex/cond/rwlock was initialized statically via one of the
PTHREAD_*_INITIALIZER macros and not being used before destruction. We now
return success (0) instead, as it would have been the case when the *_init()
function were used for initialization. This is also the behaviour Linux
exhibits.

Note that we now can no longer detect multiple calls to *_destroy(). Multiple
calls will do no harm, but return success.

While there, fix some potential null pointer derefs in cond and rwlock.

Fixes: #2763
lib/libthread_xu/thread/thr_cond.c
lib/libthread_xu/thread/thr_mutex.c
lib/libthread_xu/thread/thr_rwlock.c