[LEDE-DEV] [PATCH] make_ext4: Add strict prototypes.

Rosen Penev rosenp at gmail.com
Sat May 20 23:23:27 PDT 2017


Removes some undefined behavior.

Signed-off by: Rosen Penev <rosenp at gmail.com>
---
 allocate.h    | 10 +++++-----
 contents.c    |  8 ++++----
 contents.h    |  2 +-
 extent.h      |  2 +-
 indirect.h    |  2 +-
 make_ext4fs.c | 12 ++++++------
 6 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/allocate.h b/allocate.h
index 5c26792..a6cd073 100644
--- a/allocate.h
+++ b/allocate.h
@@ -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);
@@ -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);
-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);
@@ -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);
-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);
 
diff --git a/contents.c b/contents.c
index 1e5361e..9b65dbe 100644
--- a/contents.c
+++ b/contents.c
@@ -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) {
-		inode_num = allocate_inode(info);
+		inode_num = allocate_inode();
 	} 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;
 
-	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;
@@ -206,7 +206,7 @@ u32 make_link(const char *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;
@@ -247,7 +247,7 @@ u32 make_special(const char *path)
 		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;
diff --git a/contents.h b/contents.h
index 0a3cbd4..022b6aa 100644
--- a/contents.h
+++ b/contents.h
@@ -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);
-struct block_allocation* get_saved_allocation_chain();
+struct block_allocation* get_saved_allocation_chain(void);
 
 #endif
diff --git a/extent.h b/extent.h
index a78a7b0..e4fc4eb 100644
--- 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);
-void free_extent_blocks();
+void free_extent_blocks(void);
 
 #endif
diff --git a/indirect.h b/indirect.h
index cee8979..a503373 100644
--- a/indirect.h
+++ b/indirect.h
@@ -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);
-void free_indirect_blocks();
+void free_indirect_blocks(void);
 
 #endif
diff --git a/make_ext4fs.c b/make_ext4fs.c
index bf5f49f..051052b 100644
--- a/make_ext4fs.c
+++ b/make_ext4fs.c
@@ -258,12 +258,12 @@ static u32 build_directory_structure(const char *full_path, const char *dir_path
 	return inode;
 }
 
-static u32 compute_block_size()
+static u32 compute_block_size(void)
 {
 	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)
@@ -273,17 +273,17 @@ static u32 compute_journal_blocks()
 	return journal_blocks;
 }
 
-static u32 compute_blocks_per_group()
+static u32 compute_blocks_per_group(void)
 {
 	return info.block_size * 8;
 }
 
-static u32 compute_inodes()
+static u32 compute_inodes(void)
 {
 	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);
@@ -298,7 +298,7 @@ static u32 compute_inodes_per_group()
 	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);
-- 
2.9.4




More information about the Lede-dev mailing list