From 375ac4fa5dadae06241741c05f5a657c98eefc03 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 29 Aug 2016 11:44:32 -0600 Subject: [PATCH] filelock: bool conversion Signed-off-by: Jens Axboe --- filelock.c | 14 +++++++------- filelock.h | 4 +++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/filelock.c b/filelock.c index b1130071..6e84970f 100644 --- a/filelock.c +++ b/filelock.c @@ -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); } diff --git a/filelock.h b/filelock.h index 97d13b7a..4551bb04 100644 --- a/filelock.h +++ b/filelock.h @@ -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); -- 2.25.1