From: Jens Axboe Date: Tue, 13 Feb 2007 16:39:56 +0000 (+0100) Subject: [PATCH] Add fio_assert() X-Git-Tag: fio-1.12~95 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=0032bf9fdccc4491e779a0c581c9bcb714b012f7;p=fio.git [PATCH] Add fio_assert() A job must not call assert(), as it wont exit and set thread state properly. Signed-off-by: Jens Axboe --- diff --git a/fio.h b/fio.h index ddf66945..c0b92a6c 100644 --- a/fio.h +++ b/fio.h @@ -670,4 +670,12 @@ extern void close_ioengine(struct thread_data *); #define for_each_file(td, f, i) \ for ((i) = 0, (f) = &(td)->files[0]; (i) < (int) (td)->nr_files; (i)++, (f)++) +#define fio_assert(td, cond) do { \ + if (!(cond)) { \ + fprintf(stderr, "file:%s:%d, assert %s failed\n", __FILE__, __LINE__, #cond); \ + (td)->runstate = TD_EXITED; \ + exit(0); \ + } \ +} while (0) + #endif diff --git a/io_u.c b/io_u.c index 29c23f6f..ae92df5d 100644 --- a/io_u.c +++ b/io_u.c @@ -3,7 +3,6 @@ #include #include #include -#include #include "fio.h" #include "os.h" @@ -45,7 +44,8 @@ static void mark_random_map(struct thread_data *td, struct fio_file *f, idx = RAND_MAP_IDX(td, f, block); bit = RAND_MAP_BIT(td, f, block); - assert(idx < f->num_maps); + idx = f->num_maps; + fio_assert(td, idx < f->num_maps); f->file_map[idx] |= (1UL << bit); block++;