From ffb56c3879caa4a589bfffae2a88f52c74ec9e10 Mon Sep 17 00:00:00 2001 From: Dan Sheppard Date: Wed, 23 Apr 2025 00:11:52 +0100 Subject: [PATCH] Why'd no one tell me about bool? :-D --- src/constants.h | 3 +-- src/superblock.c | 12 ++++++------ src/superblock.h | 4 ++-- src/testvfs.c | 4 ++-- src/unix.c | 6 +++--- src/vfs.h | 6 ++++-- 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/constants.h b/src/constants.h index 9b68597..ab0d70c 100644 --- a/src/constants.h +++ b/src/constants.h @@ -2,6 +2,7 @@ #define CONSTANTS_H #include +#include #define COQUET_MAGIC 0xC0CEF11ECABBA9E5ULL #define COQUET_VERSION 0x0000000000000001ULL @@ -35,8 +36,6 @@ #define COQUET_LMODE_SHARE 1 #define COQUET_LMODE_UN 2 -typedef int bool_t; - struct coquet; typedef struct coquet coquet_t; diff --git a/src/superblock.c b/src/superblock.c index f84b03c..45dd1d9 100644 --- a/src/superblock.c +++ b/src/superblock.c @@ -108,11 +108,11 @@ static int super_init(coquet_t *cq, struct cq_super *super) { * reducing the HMAC to a simple hash in terms of guarantees. Requires the * main file to be open. */ -int cq_super_load(coquet_t *cq, struct cq_super *super, bool_t create) { +int cq_super_load(coquet_t *cq, struct cq_super *super, bool create) { uint8_t super_bytes[SUPER_BYTES]; struct cq_super super_a, super_b; int r,r2; - bool_t use_b; + bool use_b; r = (cq->vfs_funcs.read) (cq->vfs_data,COQUET_FILE_MAIN,super_bytes,0,SUPER_BYTES); @@ -149,7 +149,7 @@ int cq_super_load(coquet_t *cq, struct cq_super *super, bool_t create) { return COQUET_RET_OK; } -static int lock_super(coquet_t *cq, int mode, bool_t wait) { +static int lock_super(coquet_t *cq, int mode, bool wait) { return (cq->vfs_funcs.lock) (cq->vfs_data,COQUET_LOCK_SUPERBLOCK,mode,wait); } @@ -182,7 +182,7 @@ static void intract(uint8_t *data, struct cq_super *super, uint64_t serial) { } static int super_write(coquet_t *cq, struct cq_super *super, - bool_t use_b, uint64_t serial) { + bool use_b, uint64_t serial) { uint8_t half[HALF_BYTES]; int r; @@ -194,7 +194,7 @@ static int super_write(coquet_t *cq, struct cq_super *super, return r; } -int cq_super_save(coquet_t *cq, struct cq_super *super, bool_t wait) { +int cq_super_save(coquet_t *cq, struct cq_super *super, bool wait) { int r, ret; struct cq_super old; @@ -360,7 +360,7 @@ void test_superblock_main() { test_bail(&cq,r); } -static void make_superblock(coquet_t *cq, bool_t also_b, +static void make_superblock(coquet_t *cq, bool also_b, int corrupt, int check) { int r; struct cq_super super; diff --git a/src/superblock.h b/src/superblock.h index d9c7acf..abb9a5d 100644 --- a/src/superblock.h +++ b/src/superblock.h @@ -33,8 +33,8 @@ struct cq_super { #include "coquet.h" -int cq_super_save(coquet_t *cq, struct cq_super *super, bool_t wait); -int cq_super_load(coquet_t *cq, struct cq_super *super, bool_t create); +int cq_super_save(coquet_t *cq, struct cq_super *super, bool wait); +int cq_super_load(coquet_t *cq, struct cq_super *super, bool create); void cq_super_set_desc(struct cq_super *super, char *desc); char * cq_super_get_desc(struct cq_super *super); diff --git a/src/testvfs.c b/src/testvfs.c index fb7b7c6..5d539a2 100644 --- a/src/testvfs.c +++ b/src/testvfs.c @@ -77,7 +77,7 @@ static int test_read(void * vfs_data, int which_file, uint8_t * data, } static int test_lock(void * vfs_data, int which_lock, int lock_mode, - bool_t wait) { + bool wait) { struct test_data * td = (struct test_data *)vfs_data; return (td->vfs_funcs.lock)(td->vfs_data, @@ -90,7 +90,7 @@ static int test_delete(void *vfs_data, int which_file) { return (td->vfs_funcs.delete)(td->vfs_data, which_file); } -static int test_sync(void * vfs_data, int which_file, bool_t data_only) { +static int test_sync(void * vfs_data, int which_file, bool data_only) { struct test_data * td = (struct test_data *)vfs_data; return (td->vfs_funcs.sync)(td->vfs_data, which_file, data_only); diff --git a/src/unix.c b/src/unix.c index 6a57c4d..6c1e17b 100644 --- a/src/unix.c +++ b/src/unix.c @@ -23,7 +23,7 @@ struct unix_data { * remains owned by caller. */ static void set_error(struct unix_data * pd, char *error, - bool_t use_errno) { + bool use_errno) { pd->seen_error = 1; if(pd->error_text != NULL) { free(pd->error_text); @@ -319,7 +319,7 @@ static int min_size(struct unix_data *pd, off_t offset) { #define LOCK_BLOCK 128 static int unix_lock(void * vfs_data, int which_lock, int lock_mode, - bool_t wait) { + bool wait) { struct unix_data * pd = (struct unix_data *)vfs_data; int r, op; struct flock flk; @@ -399,7 +399,7 @@ static int unix_delete(void *vfs_data, int which_file) { return COQUET_RET_OK; } -static int unix_sync(void * vfs_data, int which_file, bool_t data_only) { +static int unix_sync(void * vfs_data, int which_file, bool data_only) { struct unix_data * pd = (struct unix_data *)vfs_data; int *fd, r; diff --git a/src/vfs.h b/src/vfs.h index 005b484..ab48168 100644 --- a/src/vfs.h +++ b/src/vfs.h @@ -31,7 +31,7 @@ typedef struct vfs { * function will wait, otherwise return COQUET_RET_LOCKED */ int (*lock)(void * vfs_data, int which_lock, int lock_mode, - bool_t wait); + bool wait); /* Open the given file. which_file is drawn from COQUET_FILE_*. * Open mode gives whether a file must (or can) be created. @@ -42,7 +42,7 @@ typedef struct vfs { int (*open)(void * vfs_data, int which_file, int open_mode); /* Sync given file to disk. */ - int (*sync)(void * vfs_data, int which_file, bool_t data_only); + int (*sync)(void * vfs_data, int which_file, bool data_only); /* Close the given file. Which_file is drawn from COQUET_FILE_*. The * file is guaranteed to be open when this function is called. If file @@ -58,6 +58,8 @@ typedef struct vfs { int (*write)(void * vfs_data, int which_file, uint8_t * data, off_t offset, uint64_t length); + // TODO write end + /* Read given data of given length at offset from to indicated file. * which file must be drawn from a COQUET_FILE_* constant. If the * offset is beyond the end of the file, all zeroes must be returned. -- 2.30.2