From 7acb0a17cb954a992ab08d925045ffff96924718 Mon Sep 17 00:00:00 2001 From: Noah Watkins Date: Tue, 7 Jan 2014 11:14:42 -0800 Subject: [PATCH] on_exit: remove side effects from asserts Signed-off-by: Noah Watkins --- src/include/on_exit.h | 3 ++- src/test/on_exit.cc | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/include/on_exit.h b/src/include/on_exit.h index 4bb8f2c06871..6510feffb9c2 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 45d22b23dc2c..26f357efa10e 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 { -- 2.47.3