trim: convert to bool
authorJens Axboe <axboe@fb.com>
Mon, 29 Aug 2016 16:37:44 +0000 (10:37 -0600)
committerJens Axboe <axboe@fb.com>
Mon, 29 Aug 2016 16:37:44 +0000 (10:37 -0600)
Signed-off-by: Jens Axboe <axboe@fb.com>
io_u.c
trim.c
trim.h

diff --git a/io_u.c b/io_u.c
index dcf7a40562531af0a55cd56ddb7d02a00527bdd6..b6d530f2a23a542d28673587ababf8a0e091f3e9 100644 (file)
--- 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 434554129453915515a5b64d47bbed6e914bf765..78cf67244efa22534604fd6b6652379457a571a2 100644 (file)
--- 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 6584606253f8edcab29e65d70f6bf23a6d49bc8d..37f5d7c871127a8bf5858a3fda620684a0e8438d 100644 (file)
--- 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)
 {