filelock: bool conversion
authorJens Axboe <axboe@fb.com>
Mon, 29 Aug 2016 17:44:32 +0000 (11:44 -0600)
committerJens Axboe <axboe@fb.com>
Mon, 29 Aug 2016 17:44:32 +0000 (11:44 -0600)
Signed-off-by: Jens Axboe <axboe@fb.com>
filelock.c
filelock.h

index b1130071ea982ad38e7277ec6c0b7886f4c84bf2..6e84970fc0064cafaeb0945befd5f4355fd9cf7b 100644 (file)
@@ -165,7 +165,7 @@ static struct fio_filelock *fio_hash_get(uint32_t hash, int trylock)
        return ff;
 }
 
-static int __fio_lock_file(const char *fname, int trylock)
+static bool __fio_lock_file(const char *fname, int trylock)
 {
        struct fio_filelock *ff;
        uint32_t hash;
@@ -180,16 +180,16 @@ static int __fio_lock_file(const char *fname, int trylock)
 
        if (!ff) {
                assert(!trylock);
-               return 1;
+               return true;
        }
 
        if (!trylock) {
                fio_mutex_down(&ff->lock);
-               return 0;
+               return false;
        }
 
        if (!fio_mutex_down_trylock(&ff->lock))
-               return 0;
+               return false;
 
        fio_mutex_down(&fld->lock);
 
@@ -206,13 +206,13 @@ static int __fio_lock_file(const char *fname, int trylock)
 
        if (ff) {
                fio_mutex_down(&ff->lock);
-               return 0;
+               return false;
        }
 
-       return 1;
+       return true;
 }
 
-int fio_trylock_file(const char *fname)
+bool fio_trylock_file(const char *fname)
 {
        return __fio_lock_file(fname, 1);
 }
index 97d13b7a62f1a62e7dbd6fc4d591588c865831a5..4551bb0427ec6fc12e726bb4161b50ad98d79c40 100644 (file)
@@ -1,8 +1,10 @@
 #ifndef FIO_LOCK_FILE_H
 #define FIO_LOCK_FILE_H
 
+#include "lib/types.h"
+
 extern void fio_lock_file(const char *);
-extern int fio_trylock_file(const char *);
+extern bool fio_trylock_file(const char *);
 extern void fio_unlock_file(const char *);
 
 extern int fio_filelock_init(void);