From b8782bdd907688c981598781928f8d0a6b9473b5 Mon Sep 17 00:00:00 2001 From: Deomid Ryabkov Date: Thu, 8 Jun 2017 17:48:17 +0100 Subject: [PATCH] Change esp_vfs_t.write return value to ssize_t write() should return ssize_t, not size_t. --- components/fatfs/src/vfs_fat.c | 4 ++-- components/vfs/README.rst | 4 ++-- components/vfs/include/esp_vfs.h | 4 ++-- components/vfs/vfs.c | 6 +++--- components/vfs/vfs_uart.c | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/components/fatfs/src/vfs_fat.c b/components/fatfs/src/vfs_fat.c index df2eb4cad..9b33bd20e 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 26d857fc8..1f47c8239 100644 --- a/components/vfs/README.rst +++ b/components/vfs/README.rst @@ -31,7 +31,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, @@ -43,7 +43,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 304750aab..a3ce6b95c 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 fff3a93a1..565edd365 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 545a5474f..4b3748764 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;