chiark / gitweb /
journal: have a named enum ObjectType
authorMichal Schmidt <mschmidt@redhat.com>
Wed, 10 Dec 2014 14:18:49 +0000 (15:18 +0100)
committerMichal Schmidt <mschmidt@redhat.com>
Fri, 12 Dec 2014 23:47:23 +0000 (00:47 +0100)
src/journal/journal-authenticate.c
src/journal/journal-authenticate.h
src/journal/journal-def.h
src/journal/journal-file.c
src/journal/journal-file.h

index 0e31c8dc9126fc0dbbd6ac2642a3132e7773cde7..b3e2601c4e18976e9a85dd85a12dfb8c81b77c75 100644 (file)
@@ -229,7 +229,7 @@ int journal_file_maybe_append_tag(JournalFile *f, uint64_t realtime) {
         return 0;
 }
 
-int journal_file_hmac_put_object(JournalFile *f, int type, Object *o, uint64_t p) {
+int journal_file_hmac_put_object(JournalFile *f, ObjectType type, Object *o, uint64_t p) {
         int r;
 
         assert(f);
index 0aaf83672136f43bfdd1ebf571c01a479cfe043a..565fe8432c7ff2369fa5ed833c090f4f6c6ca7d5 100644 (file)
@@ -33,7 +33,7 @@ int journal_file_append_first_tag(JournalFile *f);
 int journal_file_hmac_setup(JournalFile *f);
 int journal_file_hmac_start(JournalFile *f);
 int journal_file_hmac_put_header(JournalFile *f);
-int journal_file_hmac_put_object(JournalFile *f, int type, Object *o, uint64_t p);
+int journal_file_hmac_put_object(JournalFile *f, ObjectType type, Object *o, uint64_t p);
 
 int journal_file_fss_load(JournalFile *f);
 int journal_file_parse_verification_key(JournalFile *f, const char *key);
index 005e5fa149185f2d9d61830d99888145a0c78c18..ab089cb966b960eab97338b8fd07cca50613503c 100644 (file)
@@ -52,7 +52,7 @@ typedef struct HashItem HashItem;
 typedef struct FSSHeader FSSHeader;
 
 /* Object types */
-enum {
+typedef enum ObjectType {
         OBJECT_UNUSED, /* also serves as "any type" or "additional context" */
         OBJECT_DATA,
         OBJECT_FIELD,
@@ -62,7 +62,7 @@ enum {
         OBJECT_ENTRY_ARRAY,
         OBJECT_TAG,
         _OBJECT_TYPE_MAX
-};
+} ObjectType;
 
 /* Object flags */
 enum {
index 6ee0fff04c8aecf27c7de1ec6711c15e9616d974..1d73be1a2a9db8a935e79f335fda9d38e2cdb184 100644 (file)
@@ -374,7 +374,7 @@ static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size)
         return 0;
 }
 
-static unsigned type_to_context(int type) {
+static unsigned type_to_context(ObjectType type) {
         /* One context for each type, plus one catch-all for the rest */
         return type > OBJECT_UNUSED && type < _OBJECT_TYPE_MAX ? type : 0;
 }
@@ -417,7 +417,7 @@ static uint64_t minimum_header_size(Object *o) {
         return table[o->object.type];
 }
 
-int journal_file_move_to_object(JournalFile *f, int type, uint64_t offset, Object **ret) {
+int journal_file_move_to_object(JournalFile *f, ObjectType type, uint64_t offset, Object **ret) {
         int r;
         void *t;
         Object *o;
@@ -487,7 +487,7 @@ static uint64_t journal_file_entry_seqnum(JournalFile *f, uint64_t *seqnum) {
         return r;
 }
 
-int journal_file_append_object(JournalFile *f, int type, uint64_t size, Object **ret, uint64_t *offset) {
+int journal_file_append_object(JournalFile *f, ObjectType type, uint64_t size, Object **ret, uint64_t *offset) {
         int r;
         uint64_t p;
         Object *tail, *o;
index 5e8065c5a0fa2890ec4cfd704f2efed2654cc005..a4a172b50002b3edc9ceff504629216b05df49e6 100644 (file)
@@ -160,13 +160,13 @@ static inline bool VALID_EPOCH(uint64_t u) {
 #define JOURNAL_HEADER_COMPRESSED_LZ4(h) \
         (!!(le32toh((h)->incompatible_flags) & HEADER_INCOMPATIBLE_COMPRESSED_LZ4))
 
-int journal_file_move_to_object(JournalFile *f, int type, uint64_t offset, Object **ret);
+int journal_file_move_to_object(JournalFile *f, ObjectType type, uint64_t offset, Object **ret);
 
 uint64_t journal_file_entry_n_items(Object *o) _pure_;
 uint64_t journal_file_entry_array_n_items(Object *o) _pure_;
 uint64_t journal_file_hash_table_n_items(Object *o) _pure_;
 
-int journal_file_append_object(JournalFile *f, int type, uint64_t size, Object **ret, uint64_t *offset);
+int journal_file_append_object(JournalFile *f, ObjectType type, uint64_t size, Object **ret, uint64_t *offset);
 int journal_file_append_entry(JournalFile *f, const dual_timestamp *ts, const struct iovec iovec[], unsigned n_iovec, uint64_t *seqno, Object **ret, uint64_t *offset);
 
 int journal_file_find_data_object(JournalFile *f, const void *data, uint64_t size, Object **ret, uint64_t *offset);