From: Jens Axboe Date: Mon, 29 Aug 2016 16:37:44 +0000 (-0600) Subject: trim: convert to bool X-Git-Tag: fio-2.14~16 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=917c64b368adf1c687b627fd4fe3aa0f214d0cb7;hp=39d13e67ef1f4b327c68431f8daf033a03920117 trim: convert to bool Signed-off-by: Jens Axboe --- diff --git a/io_u.c b/io_u.c index dcf7a405..b6d530f2 100644 --- a/io_u.c +++ b/io_u.c @@ -1510,7 +1510,7 @@ static bool check_get_trim(struct thread_data *td, struct io_u *io_u) get_trim = 1; } - if (get_trim && !get_next_trim(td, io_u)) + if (get_trim && get_next_trim(td, io_u)) return true; } diff --git a/trim.c b/trim.c index 43455412..78cf6724 100644 --- a/trim.c +++ b/trim.c @@ -11,7 +11,7 @@ #include "trim.h" #ifdef FIO_HAVE_TRIM -int get_next_trim(struct thread_data *td, struct io_u *io_u) +bool get_next_trim(struct thread_data *td, struct io_u *io_u) { struct io_piece *ipo; @@ -19,9 +19,9 @@ int get_next_trim(struct thread_data *td, struct io_u *io_u) * this io_u is from a requeue, we already filled the offsets */ if (io_u->file) - return 0; + return true; if (flist_empty(&td->trim_list)) - return 1; + return false; assert(td->trim_entries); ipo = flist_first_entry(&td->trim_list, struct io_piece, trim_list); @@ -53,7 +53,7 @@ int get_next_trim(struct thread_data *td, struct io_u *io_u) if (r) { dprint(FD_VERIFY, "failed file %s open\n", io_u->file->file_name); - return 1; + return false; } } @@ -64,17 +64,17 @@ int get_next_trim(struct thread_data *td, struct io_u *io_u) io_u->xfer_buflen = io_u->buflen; dprint(FD_VERIFY, "get_next_trim: ret io_u %p\n", io_u); - return 0; + return true; } -int io_u_should_trim(struct thread_data *td, struct io_u *io_u) +bool io_u_should_trim(struct thread_data *td, struct io_u *io_u) { unsigned long long val; uint64_t frand_max; unsigned long r; if (!td->o.trim_percentage) - return 0; + return false; frand_max = rand_max(&td->trim_state); r = __rand(&td->trim_state); diff --git a/trim.h b/trim.h index 65846062..37f5d7c8 100644 --- a/trim.h +++ b/trim.h @@ -4,8 +4,8 @@ #include "fio.h" #ifdef FIO_HAVE_TRIM -extern int __must_check get_next_trim(struct thread_data *td, struct io_u *io_u); -extern int io_u_should_trim(struct thread_data *td, struct io_u *io_u); +extern bool __must_check get_next_trim(struct thread_data *td, struct io_u *io_u); +extern bool io_u_should_trim(struct thread_data *td, struct io_u *io_u); /* * Determine whether a given io_u should be logged for verify or @@ -20,13 +20,13 @@ static inline void remove_trim_entry(struct thread_data *td, struct io_piece *ip } #else -static inline int get_next_trim(struct thread_data *td, struct io_u *io_u) +static inline bool get_next_trim(struct thread_data *td, struct io_u *io_u) { - return 1; + return false; } -static inline int io_u_should_trim(struct thread_data *td, struct io_u *io_u) +static inline bool io_u_should_trim(struct thread_data *td, struct io_u *io_u) { - return 0; + return false; } static inline void remove_trim_entry(struct thread_data *td, struct io_piece *ipo) {