chiark / gitweb /
Why'd no one tell me about bool? :-D
authorDan Sheppard <dan.sheppard.circle@gmail.com>
Tue, 22 Apr 2025 23:11:52 +0000 (00:11 +0100)
committerDan Sheppard <dan.sheppard.circle@gmail.com>
Tue, 22 Apr 2025 23:11:52 +0000 (00:11 +0100)
src/constants.h
src/superblock.c
src/superblock.h
src/testvfs.c
src/unix.c
src/vfs.h

index 9b68597e9aff5a6a7c31833959d2d1852a07d3e4..ab0d70cfae300e17094d4fa061be70b9dfba9e94 100644 (file)
@@ -2,6 +2,7 @@
 #define CONSTANTS_H
 
 #include <stdint.h>
+#include <stdbool.h>
 
 #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;
 
index f84b03c412ddc048c0573549f5abef3f29b1ce58..45dd1d9a06f6356bfbc82414be03c4d114a45c0e 100644 (file)
@@ -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;
index d9c7acf57ee941c829004e16a894cc20ea5fbc81..abb9a5d23922473dc1d1175367442b66260a4854 100644 (file)
@@ -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);
 
index fb7b7c6c97ca31916251e6913827613807e8209a..5d539a26595cb4d35818ca8f101b290964f4d27e 100644 (file)
@@ -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);
index 6a57c4ddcf4a71bd9638bb5505a91cc412293b16..6c1e17b34a738f7ca9c79c8dd39f1d33de1c4cd4 100644 (file)
@@ -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;
 
index 005b484a7ad43ce0817c0e4c8c255d7eb79b183e..ab481689ec4ee7e62ec2f8e92ea85385be6cb886 100644 (file)
--- 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.