Make sure that assert() expressions do not have side effects
authorBart Van Assche <bart.vanassche@wdc.com>
Fri, 16 Mar 2018 15:44:35 +0000 (08:44 -0700)
committerBart Van Assche <bart.vanassche@wdc.com>
Fri, 16 Mar 2018 19:31:20 +0000 (12:31 -0700)
Assert statements are compiled out if NDEBUG is defined. Hence make sure
that the expressions passed to assert do not have side effects.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
io_u.c

diff --git a/io_u.c b/io_u.c
index 01b36938d1b5b8730c5e427fc278131c2a860487..84d9315512c9d5b4c1b68924f341daa05fbb4d82 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -1558,6 +1558,7 @@ bool queue_full(const struct thread_data *td)
 struct io_u *__get_io_u(struct thread_data *td)
 {
        struct io_u *io_u = NULL;
 struct io_u *__get_io_u(struct thread_data *td)
 {
        struct io_u *io_u = NULL;
+       int ret;
 
        if (td->stop_io)
                return NULL;
 
        if (td->stop_io)
                return NULL;
@@ -1594,7 +1595,8 @@ again:
                 * return one
                 */
                assert(!(td->flags & TD_F_CHILD));
                 * return one
                 */
                assert(!(td->flags & TD_F_CHILD));
-               assert(!pthread_cond_wait(&td->free_cond, &td->io_u_lock));
+               ret = pthread_cond_wait(&td->free_cond, &td->io_u_lock);
+               assert(ret == 0);
                goto again;
        }
 
                goto again;
        }