From: Nicholas Nethercote Date: Mon, 26 Apr 2004 08:05:24 +0000 (+0000) Subject: Split some combined error messages, so they are more informative. Also return X-Git-Tag: svn/VALGRIND_2_1_2~120 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=51a32b0907ade460f2dd228ff03e7880f43b8aaa;p=thirdparty%2Fvalgrind.git Split some combined error messages, so they are more informative. Also return EPERM where appropriate, instead of EINVAL. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2387 --- diff --git a/coregrind/vg_scheduler.c b/coregrind/vg_scheduler.c index a20af0b53f..53a967009d 100644 --- a/coregrind/vg_scheduler.c +++ b/coregrind/vg_scheduler.c @@ -2368,9 +2368,16 @@ void do_pthread_cond_wait ( ThreadId tid, vg_assert(VG_(is_valid_tid)(tid) && VG_(threads)[tid].status == VgTs_Runnable); - if (mutex == NULL || cond == NULL) { + if (mutex == NULL) { + VG_(record_pthread_error)( tid, + "pthread_cond_wait/timedwait: mutex is NULL"); + SET_PTHREQ_RETVAL(tid, VKI_EINVAL); + return; + } + + if (cond == NULL) { VG_(record_pthread_error)( tid, - "pthread_cond_wait/timedwait: cond or mutex is NULL"); + "pthread_cond_wait/timedwait: cond is NULL"); SET_PTHREQ_RETVAL(tid, VKI_EINVAL); return; } @@ -2396,12 +2403,17 @@ void do_pthread_cond_wait ( ThreadId tid, } /* Barf if we don't currently hold the mutex. */ - if (mutex->__vg_m_count == 0 /* nobody holds it */ - || (ThreadId)mutex->__vg_m_owner != tid /* we don't hold it */) { + if (mutex->__vg_m_count == 0 /* nobody holds it */) { VG_(record_pthread_error)( tid, - "pthread_cond_wait/timedwait: mutex is unlocked " - "or is locked but not owned by thread"); - SET_PTHREQ_RETVAL(tid, VKI_EINVAL); + "pthread_cond_wait/timedwait: mutex is unlocked"); + SET_PTHREQ_RETVAL(tid, VKI_EPERM); + return; + } + + if ((ThreadId)mutex->__vg_m_owner != tid /* we don't hold it */) { + VG_(record_pthread_error)( tid, + "pthread_cond_wait/timedwait: mutex is locked by another thread"); + SET_PTHREQ_RETVAL(tid, VKI_EPERM); return; }