From b4f1a2a663deb75318f1af95a90fed64b53b13b4 Mon Sep 17 00:00:00 2001 From: gkostka Date: Sun, 20 Sep 2015 19:41:28 +0200 Subject: [PATCH 1/2] Code format (spaces to tabs) --- lwext4/ext4_dir_idx.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/lwext4/ext4_dir_idx.c b/lwext4/ext4_dir_idx.c index 7f0953b..a34fc50 100644 --- a/lwext4/ext4_dir_idx.c +++ b/lwext4/ext4_dir_idx.c @@ -1193,28 +1193,29 @@ release_index: return rc2; } -int ext4_dir_dx_reset_parent_inode(struct ext4_inode_ref *dir, uint32_t parent_inode) +int ext4_dir_dx_reset_parent_inode(struct ext4_inode_ref *dir, + uint32_t parent_inode) { - /* Load block 0, where will be index root located */ - uint32_t fblock; - int rc = ext4_fs_get_inode_data_block_index(dir, 0, &fblock); - if (rc != EOK) - return rc; + /* Load block 0, where will be index root located */ + uint32_t fblock; + int rc = ext4_fs_get_inode_data_block_index(dir, 0, &fblock); + if (rc != EOK) + return rc; - struct ext4_block block; - rc = ext4_block_get(dir->fs->bdev, &block, fblock); - if (rc != EOK) - return rc; + struct ext4_block block; + rc = ext4_block_get(dir->fs->bdev, &block, fblock); + if (rc != EOK) + return rc; - /* Initialize pointers to data structures */ - struct ext4_directory_dx_root *root = (void *)block.data; + /* Initialize pointers to data structures */ + struct ext4_directory_dx_root *root = (void *)block.data; - /* Fill the inode field with a new parent ino. */ - ext4_dx_dot_entry_set_inode(&root->dots[1], parent_inode); + /* Fill the inode field with a new parent ino. */ + ext4_dx_dot_entry_set_inode(&root->dots[1], parent_inode); - block.dirty = true; + block.dirty = true; - return ext4_block_set(dir->fs->bdev, &block); + return ext4_block_set(dir->fs->bdev, &block); } /** From 07058c189962c6e71f56bfbd282b979556150bed Mon Sep 17 00:00:00 2001 From: gkostka Date: Sun, 20 Sep 2015 20:16:19 +0200 Subject: [PATCH 2/2] Change ext4_fread & ext4_fwrite prototypes It is better idea to pass size_t type to fwrite & fread instead of uint32_t. --- demos/chibios/common/test_lwext4.c | 2 +- demos/generic/main.c | 2 +- demos/stm32f429_disco/main.c | 2 +- fs_test/lwext4_server.c | 15 ++++++++------- lwext4/ext4.c | 4 ++-- lwext4/ext4.h | 5 +++-- 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/demos/chibios/common/test_lwext4.c b/demos/chibios/common/test_lwext4.c index 8a0adcf..4976d6f 100644 --- a/demos/chibios/common/test_lwext4.c +++ b/demos/chibios/common/test_lwext4.c @@ -222,7 +222,7 @@ static int verify_buf(const unsigned char *b, size_t len, unsigned char c) bool test_lwext4_file_test(uint32_t rw_szie, uint32_t rw_count) { int r; - uint32_t size; + size_t size; uint32_t i; clock_t start; clock_t stop; diff --git a/demos/generic/main.c b/demos/generic/main.c index f77823e..079fb5b 100644 --- a/demos/generic/main.c +++ b/demos/generic/main.c @@ -256,7 +256,7 @@ static bool dir_test(int len) static bool file_test(void) { int r; - uint32_t size; + size_t size; ext4_file f; int i; clock_t start; diff --git a/demos/stm32f429_disco/main.c b/demos/stm32f429_disco/main.c index 83339ab..c9ca86c 100644 --- a/demos/stm32f429_disco/main.c +++ b/demos/stm32f429_disco/main.c @@ -247,7 +247,7 @@ static bool dir_test(int len) static bool file_test(void) { int r; - uint32_t size; + size_t size; ext4_file f; int i; clock_t start; diff --git a/fs_test/lwext4_server.c b/fs_test/lwext4_server.c index 4c9c96a..32b37bd 100644 --- a/fs_test/lwext4_server.c +++ b/fs_test/lwext4_server.c @@ -550,7 +550,7 @@ int _fread(char *p) int len; int d; int rc; - int rb; + size_t rb; if (sscanf(p, "%d %d %d %d", &fid, &d, &len, &d) != 4) { printf("Param list error\n"); @@ -595,10 +595,11 @@ int _fread(char *p) int _fwrite(char *p) { int fid = MAX_FILES; - int len; int d; int rc; - int wb; + + size_t len; + size_t wb; if (sscanf(p, "%d %d %d %d", &fid, &d, &len, &d) != 4) { printf("Param list error\n"); @@ -867,10 +868,10 @@ int _multi_fwrite(char *p) char path[256]; char path1[256]; char prefix[32]; - int cnt; + int cnt, i; int len, ll; int rc; - int i, d, wb; + size_t d, wb; ext4_file fd; if (sscanf(p, "%s %s %d %d", path, prefix, &cnt, &ll) != 4) { @@ -912,8 +913,8 @@ int _multi_fread(char *p) char prefix[32]; int cnt; int len, ll; - int rc; - int i, d, rb; + int rc ,i, d; + size_t rb; ext4_file fd; if (sscanf(p, "%s %s %d %d", path, prefix, &cnt, &ll) != 4) { diff --git a/lwext4/ext4.c b/lwext4/ext4.c index 4e47834..fb8b7f8 100644 --- a/lwext4/ext4.c +++ b/lwext4/ext4.c @@ -1237,7 +1237,7 @@ int ext4_ftruncate(ext4_file *f, uint64_t size) return r; } -int ext4_fread(ext4_file *f, void *buf, uint32_t size, uint32_t *rcnt) +int ext4_fread(ext4_file *f, void *buf, size_t size, size_t *rcnt) { uint32_t u; uint32_t fblock; @@ -1371,7 +1371,7 @@ Finish: return r; } -int ext4_fwrite(ext4_file *f, const void *buf, uint32_t size, uint32_t *wcnt) +int ext4_fwrite(ext4_file *f, const void *buf, size_t size, size_t *wcnt) { uint32_t u; uint32_t fblock; diff --git a/lwext4/ext4.h b/lwext4/ext4.h index 4328c22..6bd3390 100644 --- a/lwext4/ext4.h +++ b/lwext4/ext4.h @@ -43,6 +43,7 @@ #include "ext4_blockdev.h" #include +#include /********************************FILE OPEN FLAGS*****************************/ @@ -323,7 +324,7 @@ int ext4_ftruncate(ext4_file *f, uint64_t size); * @param size bytes to read * @param rcnt bytes read (may be NULL) * @return standard error code*/ -int ext4_fread(ext4_file *f, void *buf, uint32_t size, uint32_t *rcnt); +int ext4_fread(ext4_file *f, void *buf, size_t size, size_t *rcnt); /**@brief Write data to file. * @param f file handle @@ -331,7 +332,7 @@ int ext4_fread(ext4_file *f, void *buf, uint32_t size, uint32_t *rcnt); * @param size write length * @param wcnt bytes written (may be NULL) * @return standard error code*/ -int ext4_fwrite(ext4_file *f, const void *buf, uint32_t size, uint32_t *wcnt); +int ext4_fwrite(ext4_file *f, const void *buf, size_t size, size_t *wcnt); /**@brief File seek operation. * @param f file handle