shithub: lwext4

Download patch

ref: 11246ef8f6a660a6cb9b4b12dcde6b304bb75810
parent: c1adeee6bee2febf7a4da6fb76d7f0ce06c57ff2
author: gkostka <kostka.grzegorz@gmail.com>
date: Sun Sep 20 16:16:19 EDT 2015

Change ext4_fread & ext4_fwrite prototypes

It is better idea  to pass size_t type to fwrite & fread instead of uint32_t.

--- a/demos/chibios/common/test_lwext4.c
+++ b/demos/chibios/common/test_lwext4.c
@@ -222,7 +222,7 @@
 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;
--- a/demos/generic/main.c
+++ b/demos/generic/main.c
@@ -256,7 +256,7 @@
 static bool file_test(void)
 {
 	int r;
-	uint32_t size;
+	size_t size;
 	ext4_file f;
 	int i;
 	clock_t start;
--- a/demos/stm32f429_disco/main.c
+++ b/demos/stm32f429_disco/main.c
@@ -247,7 +247,7 @@
 static bool file_test(void)
 {
     int r;
-    uint32_t  size;
+    size_t  size;
     ext4_file f;
     int i;
     clock_t start;
--- a/fs_test/lwext4_server.c
+++ b/fs_test/lwext4_server.c
@@ -550,7 +550,7 @@
 	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,11 +595,12 @@
 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");
 		return -1;
@@ -867,10 +868,10 @@
 	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 @@
 	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) {
--- a/lwext4/ext4.c
+++ b/lwext4/ext4.c
@@ -1236,7 +1236,7 @@
 	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;
@@ -1370,7 +1370,7 @@
 	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;
--- a/lwext4/ext4.h
+++ b/lwext4/ext4.h
@@ -43,6 +43,7 @@
 #include "ext4_blockdev.h"
 
 #include <stdint.h>
+#include <stddef.h>
 
 /********************************FILE OPEN FLAGS*****************************/
 
@@ -323,7 +324,7 @@
  * @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 @@
  * @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