]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
on_exit: remove side effects from asserts 1044/head
authorNoah Watkins <noahwatkins@gmail.com>
Tue, 7 Jan 2014 19:14:42 +0000 (11:14 -0800)
committerNoah Watkins <noahwatkins@gmail.com>
Tue, 7 Jan 2014 19:14:42 +0000 (11:14 -0800)
Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
src/include/on_exit.h
src/test/on_exit.cc

index 4bb8f2c0687154e9a08a696b72f4390d17c26a88..6510feffb9c2bfcc9559bf65cc80ab30545fe2f5 100644 (file)
@@ -15,7 +15,8 @@ class OnExitManager {
     typedef void (*callback_t)(void *arg);
 
     OnExitManager() {
-      assert(pthread_mutex_init(&lock_, NULL) == 0);
+      int ret = pthread_mutex_init(&lock_, NULL);
+      assert(ret == 0);
     }
 
     ~OnExitManager() {
index 45d22b23dc2c846a899cd946b8781d256756a66e..26f357efa10e483759a59266f94fb411fdccd05c 100644 (file)
@@ -73,7 +73,8 @@ int main(int argc, char **argv)
   assert(pid >= 0);
   if (pid) {
     int status;
-    assert(pid == waitpid(pid, &status, 0));
+    int ret = waitpid(pid, &status, 0);
+    assert(ret == pid); // should be our child
     assert(status == 0);
     assert(*shared_val == MAIN_SCOPE_VAL);
   } else {
@@ -93,7 +94,8 @@ int main(int argc, char **argv)
   assert(pid >= 0);
   if (pid) {
     int status;
-    assert(pid == waitpid(pid, &status, 0));
+    int ret = waitpid(pid, &status, 0);
+    assert(ret == pid); // should be our child
     assert(WEXITSTATUS(status) == 3);
     assert(*shared_val == EXIT_FUNC_VAL);
   } else {