diff --git a/components/fatfs/src/vfs_fat.c b/components/fatfs/src/vfs_fat.c index df2eb4cadf..9b33bd20e6 100644 --- a/components/fatfs/src/vfs_fat.c +++ b/components/fatfs/src/vfs_fat.c @@ -45,7 +45,7 @@ typedef struct { static const char* TAG = "vfs_fat"; -static size_t vfs_fat_write(void* p, int fd, const void * data, size_t size); +static ssize_t vfs_fat_write(void* p, int fd, const void * data, size_t size); static off_t vfs_fat_lseek(void* p, int fd, off_t size, int mode); static ssize_t vfs_fat_read(void* ctx, int fd, void * dst, size_t size); static int vfs_fat_open(void* ctx, const char * path, int flags, int mode); @@ -290,7 +290,7 @@ out: return fd; } -static size_t vfs_fat_write(void* ctx, int fd, const void * data, size_t size) +static ssize_t vfs_fat_write(void* ctx, int fd, const void * data, size_t size) { vfs_fat_ctx_t* fat_ctx = (vfs_fat_ctx_t*) ctx; FIL* file = &fat_ctx->files[fd]; diff --git a/components/vfs/README.rst b/components/vfs/README.rst index 318004c250..ebd30ba0b1 100644 --- a/components/vfs/README.rst +++ b/components/vfs/README.rst @@ -37,7 +37,7 @@ Depending on the way FS driver declares its APIs, either ``read``, ``write``, et Case 1: API functions are declared without an extra context pointer (FS driver is a singleton):: - size_t myfs_write(int fd, const void * data, size_t size); + ssize_t myfs_write(int fd, const void * data, size_t size); // In definition of esp_vfs_t: .flags = ESP_VFS_FLAG_DEFAULT, @@ -49,7 +49,7 @@ Case 1: API functions are declared without an extra context pointer (FS driver i Case 2: API functions are declared with an extra context pointer (FS driver supports multiple instances):: - size_t myfs_write(myfs_t* fs, int fd, const void * data, size_t size); + ssize_t myfs_write(myfs_t* fs, int fd, const void * data, size_t size); // In definition of esp_vfs_t: .flags = ESP_VFS_FLAG_CONTEXT_PTR, diff --git a/components/vfs/include/esp_vfs.h b/components/vfs/include/esp_vfs.h index 304750aabd..a3ce6b95cf 100644 --- a/components/vfs/include/esp_vfs.h +++ b/components/vfs/include/esp_vfs.h @@ -69,8 +69,8 @@ typedef struct int fd_offset; /*!< file descriptor offset, determined by the FS driver */ int flags; /*!< ESP_VFS_FLAG_CONTEXT_PTR or ESP_VFS_FLAG_DEFAULT */ union { - size_t (*write_p)(void* p, int fd, const void * data, size_t size); - size_t (*write)(int fd, const void * data, size_t size); + ssize_t (*write_p)(void* p, int fd, const void * data, size_t size); + ssize_t (*write)(int fd, const void * data, size_t size); }; union { off_t (*lseek_p)(void* p, int fd, off_t size, int mode); diff --git a/components/vfs/vfs.c b/components/vfs/vfs.c index fff3a93a1d..565edd3659 100644 --- a/components/vfs/vfs.c +++ b/components/vfs/vfs.c @@ -213,7 +213,7 @@ ssize_t esp_vfs_write(struct _reent *r, int fd, const void * data, size_t size) return -1; } int local_fd = translate_fd(vfs, fd); - int ret; + ssize_t ret; CHECK_AND_CALL(ret, r, vfs, write, local_fd, data, size); return ret; } @@ -226,7 +226,7 @@ off_t esp_vfs_lseek(struct _reent *r, int fd, off_t size, int mode) return -1; } int local_fd = translate_fd(vfs, fd); - int ret; + off_t ret; CHECK_AND_CALL(ret, r, vfs, lseek, local_fd, size, mode); return ret; } @@ -239,7 +239,7 @@ ssize_t esp_vfs_read(struct _reent *r, int fd, void * dst, size_t size) return -1; } int local_fd = translate_fd(vfs, fd); - int ret; + ssize_t ret; CHECK_AND_CALL(ret, r, vfs, read, local_fd, dst, size); return ret; } diff --git a/components/vfs/vfs_uart.c b/components/vfs/vfs_uart.c index 545a5474fa..4b37487649 100644 --- a/components/vfs/vfs_uart.c +++ b/components/vfs/vfs_uart.c @@ -47,7 +47,7 @@ static void IRAM_ATTR uart_tx_char(uart_dev_t* uart, int c) } -static size_t IRAM_ATTR uart_write(int fd, const void * data, size_t size) +static ssize_t IRAM_ATTR uart_write(int fd, const void * data, size_t size) { assert(fd >=0 && fd < 3); const char *data_c = (const char *)data;