]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Split some combined error messages, so they are more informative. Also return
authorNicholas Nethercote <n.nethercote@gmail.com>
Mon, 26 Apr 2004 08:05:24 +0000 (08:05 +0000)
committerNicholas Nethercote <n.nethercote@gmail.com>
Mon, 26 Apr 2004 08:05:24 +0000 (08:05 +0000)
EPERM where appropriate, instead of EINVAL.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2387

coregrind/vg_scheduler.c

index a20af0b53fcffa5cbf0db629136278800b870606..53a967009dc7e6e17e320027d2f1772d3a528c73 100644 (file)
@@ -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;
    }