From: Noah Watkins Date: Tue, 7 Jan 2014 19:14:42 +0000 (-0800) Subject: on_exit: remove side effects from asserts X-Git-Tag: v0.77~41^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F1044%2Fhead;p=ceph.git on_exit: remove side effects from asserts Signed-off-by: Noah Watkins --- diff --git a/src/include/on_exit.h b/src/include/on_exit.h index 4bb8f2c0687..6510feffb9c 100644 --- a/src/include/on_exit.h +++ b/src/include/on_exit.h @@ -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() { diff --git a/src/test/on_exit.cc b/src/test/on_exit.cc index 45d22b23dc2..26f357efa10 100644 --- a/src/test/on_exit.cc +++ b/src/test/on_exit.cc @@ -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 {