make_ext4: Add strict prototypes. master
authorRosen Penev <rosenp@gmail.com>
Sun, 21 May 2017 06:23:27 +0000 (23:23 -0700)
committerJohn Crispin <john@phrozen.org>
Mon, 29 May 2017 06:44:46 +0000 (08:44 +0200)
Removes some undefined behavior.

Signed-off by: Rosen Penev <rosenp@gmail.com>

allocate.h
contents.c
contents.h
extent.h
indirect.h
make_ext4fs.c

index 5c26792..a6cd073 100644 (file)
@@ -38,9 +38,9 @@ struct block_allocation {
 };
 
 
 };
 
 
-void block_allocator_init();
-void block_allocator_free();
-u32 allocate_block();
+void block_allocator_init(void);
+void block_allocator_free(void);
+u32 allocate_block(void);
 struct block_allocation *allocate_blocks(u32 len);
 int block_allocation_num_regions(struct block_allocation *alloc);
 int block_allocation_len(struct block_allocation *alloc);
 struct block_allocation *allocate_blocks(u32 len);
 int block_allocation_num_regions(struct block_allocation *alloc);
 int block_allocation_len(struct block_allocation *alloc);
@@ -58,7 +58,7 @@ void add_directory(u32 inode);
 u16 get_directories(int bg);
 u16 get_bg_flags(int bg);
 void init_unused_inode_tables(void);
 u16 get_directories(int bg);
 u16 get_bg_flags(int bg);
 void init_unused_inode_tables(void);
-u32 allocate_inode();
+u32 allocate_inode(void);
 void free_alloc(struct block_allocation *alloc);
 int reserve_oob_blocks(struct block_allocation *alloc, int blocks);
 int advance_blocks(struct block_allocation *alloc, int blocks);
 void free_alloc(struct block_allocation *alloc);
 int reserve_oob_blocks(struct block_allocation *alloc, int blocks);
 int advance_blocks(struct block_allocation *alloc, int blocks);
@@ -67,7 +67,7 @@ int last_region(struct block_allocation *alloc);
 void rewind_alloc(struct block_allocation *alloc);
 void append_region(struct block_allocation *alloc,
        u32 block, u32 len, int bg);
 void rewind_alloc(struct block_allocation *alloc);
 void append_region(struct block_allocation *alloc,
        u32 block, u32 len, int bg);
-struct block_allocation *create_allocation();
+struct block_allocation *create_allocation(void);
 int append_oob_allocation(struct block_allocation *alloc, u32 len);
 void print_blocks(FILE* f, struct block_allocation *alloc);
 
 int append_oob_allocation(struct block_allocation *alloc, u32 len);
 void print_blocks(FILE* f, struct block_allocation *alloc);
 
index 1e5361e..9b65dbe 100644 (file)
@@ -103,7 +103,7 @@ u32 make_directory(u32 dir_inode_num, u32 entries, struct dentry *dentries,
        len = blocks * info.block_size;
 
        if (dir_inode_num) {
        len = blocks * info.block_size;
 
        if (dir_inode_num) {
-               inode_num = allocate_inode(info);
+               inode_num = allocate_inode();
        } else {
                dir_inode_num = EXT4_ROOT_INO;
                inode_num = EXT4_ROOT_INO;
        } else {
                dir_inode_num = EXT4_ROOT_INO;
                inode_num = EXT4_ROOT_INO;
@@ -171,7 +171,7 @@ u32 make_file(const char *filename, u64 len)
        struct ext4_inode *inode;
        u32 inode_num;
 
        struct ext4_inode *inode;
        u32 inode_num;
 
-       inode_num = allocate_inode(info);
+       inode_num = allocate_inode();
        if (inode_num == EXT4_ALLOCATE_FAILED) {
                error("failed to allocate inode\n");
                return EXT4_ALLOCATE_FAILED;
        if (inode_num == EXT4_ALLOCATE_FAILED) {
                error("failed to allocate inode\n");
                return EXT4_ALLOCATE_FAILED;
@@ -206,7 +206,7 @@ u32 make_link(const char *link)
        u32 inode_num;
        u32 len = strlen(link);
 
        u32 inode_num;
        u32 len = strlen(link);
 
-       inode_num = allocate_inode(info);
+       inode_num = allocate_inode();
        if (inode_num == EXT4_ALLOCATE_FAILED) {
                error("failed to allocate inode\n");
                return EXT4_ALLOCATE_FAILED;
        if (inode_num == EXT4_ALLOCATE_FAILED) {
                error("failed to allocate inode\n");
                return EXT4_ALLOCATE_FAILED;
@@ -247,7 +247,7 @@ u32 make_special(const char *path)
                return EXT4_ALLOCATE_FAILED;
        }
 
                return EXT4_ALLOCATE_FAILED;
        }
 
-       inode_num = allocate_inode(info);
+       inode_num = allocate_inode();
        if (inode_num == EXT4_ALLOCATE_FAILED) {
                error("failed to allocate inode\n");
                return EXT4_ALLOCATE_FAILED;
        if (inode_num == EXT4_ALLOCATE_FAILED) {
                error("failed to allocate inode\n");
                return EXT4_ALLOCATE_FAILED;
index 0a3cbd4..022b6aa 100644 (file)
@@ -39,6 +39,6 @@ u32 make_link(const char *link);
 u32 make_special(const char *path);
 int inode_set_permissions(u32 inode_num, u16 mode, u16 uid, u16 gid, u32 mtime);
 int inode_set_capabilities(u32 inode_num, uint64_t capabilities);
 u32 make_special(const char *path);
 int inode_set_permissions(u32 inode_num, u16 mode, u16 uid, u16 gid, u32 mtime);
 int inode_set_capabilities(u32 inode_num, uint64_t capabilities);
-struct block_allocation* get_saved_allocation_chain();
+struct block_allocation* get_saved_allocation_chain(void);
 
 #endif
 
 #endif
index a78a7b0..e4fc4eb 100644 (file)
--- a/extent.h
+++ b/extent.h
@@ -25,6 +25,6 @@ struct block_allocation* inode_allocate_file_extents(
        struct ext4_inode *inode, u64 len, const char *filename);
 u8 *inode_allocate_data_extents(struct ext4_inode *inode, u64 len,
        u64 backing_len);
        struct ext4_inode *inode, u64 len, const char *filename);
 u8 *inode_allocate_data_extents(struct ext4_inode *inode, u64 len,
        u64 backing_len);
-void free_extent_blocks();
+void free_extent_blocks(void);
 
 #endif
 
 #endif
index cee8979..a503373 100644 (file)
@@ -24,6 +24,6 @@ u8 *inode_allocate_data_indirect(struct ext4_inode *inode, unsigned long len,
        unsigned long backing_len);
 void inode_attach_resize(struct ext4_inode *inode,
                struct block_allocation *alloc);
        unsigned long backing_len);
 void inode_attach_resize(struct ext4_inode *inode,
                struct block_allocation *alloc);
-void free_indirect_blocks();
+void free_indirect_blocks(void);
 
 #endif
 
 #endif
index bf5f49f..051052b 100644 (file)
@@ -258,12 +258,12 @@ static u32 build_directory_structure(const char *full_path, const char *dir_path
        return inode;
 }
 
        return inode;
 }
 
-static u32 compute_block_size()
+static u32 compute_block_size(void)
 {
        return 4096;
 }
 
 {
        return 4096;
 }
 
-static u32 compute_journal_blocks()
+static u32 compute_journal_blocks(void)
 {
        u32 journal_blocks = DIV_ROUND_UP(info.len, info.block_size) / 64;
        if (journal_blocks < 1024)
 {
        u32 journal_blocks = DIV_ROUND_UP(info.len, info.block_size) / 64;
        if (journal_blocks < 1024)
@@ -273,17 +273,17 @@ static u32 compute_journal_blocks()
        return journal_blocks;
 }
 
        return journal_blocks;
 }
 
-static u32 compute_blocks_per_group()
+static u32 compute_blocks_per_group(void)
 {
        return info.block_size * 8;
 }
 
 {
        return info.block_size * 8;
 }
 
-static u32 compute_inodes()
+static u32 compute_inodes(void)
 {
        return DIV_ROUND_UP(info.len, info.block_size) / 4;
 }
 
 {
        return DIV_ROUND_UP(info.len, info.block_size) / 4;
 }
 
-static u32 compute_inodes_per_group()
+static u32 compute_inodes_per_group(void)
 {
        u32 blocks = DIV_ROUND_UP(info.len, info.block_size);
        u32 block_groups = DIV_ROUND_UP(blocks, info.blocks_per_group);
 {
        u32 blocks = DIV_ROUND_UP(info.len, info.block_size);
        u32 block_groups = DIV_ROUND_UP(blocks, info.blocks_per_group);
@@ -298,7 +298,7 @@ static u32 compute_inodes_per_group()
        return inodes;
 }
 
        return inodes;
 }
 
-static u32 compute_bg_desc_reserve_blocks()
+static u32 compute_bg_desc_reserve_blocks(void)
 {
        u32 blocks = DIV_ROUND_UP(info.len, info.block_size);
        u32 block_groups = DIV_ROUND_UP(blocks, info.blocks_per_group);
 {
        u32 blocks = DIV_ROUND_UP(info.len, info.block_size);
        u32 block_groups = DIV_ROUND_UP(blocks, info.blocks_per_group);