mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-02 12:14:32 +02:00
Merge branch 'bugfix/vfs_write_return_type' into 'master'
Change esp_vfs_t.write return value to ssize_t See merge request !897
This commit is contained in:
@@ -45,7 +45,7 @@ typedef struct {
|
|||||||
|
|
||||||
static const char* TAG = "vfs_fat";
|
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 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 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);
|
static int vfs_fat_open(void* ctx, const char * path, int flags, int mode);
|
||||||
@@ -290,7 +290,7 @@ out:
|
|||||||
return fd;
|
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;
|
vfs_fat_ctx_t* fat_ctx = (vfs_fat_ctx_t*) ctx;
|
||||||
FIL* file = &fat_ctx->files[fd];
|
FIL* file = &fat_ctx->files[fd];
|
||||||
|
@@ -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)::
|
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:
|
// In definition of esp_vfs_t:
|
||||||
.flags = ESP_VFS_FLAG_DEFAULT,
|
.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)::
|
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:
|
// In definition of esp_vfs_t:
|
||||||
.flags = ESP_VFS_FLAG_CONTEXT_PTR,
|
.flags = ESP_VFS_FLAG_CONTEXT_PTR,
|
||||||
|
@@ -69,8 +69,8 @@ typedef struct
|
|||||||
int fd_offset; /*!< file descriptor offset, determined by the FS driver */
|
int fd_offset; /*!< file descriptor offset, determined by the FS driver */
|
||||||
int flags; /*!< ESP_VFS_FLAG_CONTEXT_PTR or ESP_VFS_FLAG_DEFAULT */
|
int flags; /*!< ESP_VFS_FLAG_CONTEXT_PTR or ESP_VFS_FLAG_DEFAULT */
|
||||||
union {
|
union {
|
||||||
size_t (*write_p)(void* p, int fd, const void * data, size_t size);
|
ssize_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)(int fd, const void * data, size_t size);
|
||||||
};
|
};
|
||||||
union {
|
union {
|
||||||
off_t (*lseek_p)(void* p, int fd, off_t size, int mode);
|
off_t (*lseek_p)(void* p, int fd, off_t size, int mode);
|
||||||
|
@@ -213,7 +213,7 @@ ssize_t esp_vfs_write(struct _reent *r, int fd, const void * data, size_t size)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int local_fd = translate_fd(vfs, fd);
|
int local_fd = translate_fd(vfs, fd);
|
||||||
int ret;
|
ssize_t ret;
|
||||||
CHECK_AND_CALL(ret, r, vfs, write, local_fd, data, size);
|
CHECK_AND_CALL(ret, r, vfs, write, local_fd, data, size);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -226,7 +226,7 @@ off_t esp_vfs_lseek(struct _reent *r, int fd, off_t size, int mode)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int local_fd = translate_fd(vfs, fd);
|
int local_fd = translate_fd(vfs, fd);
|
||||||
int ret;
|
off_t ret;
|
||||||
CHECK_AND_CALL(ret, r, vfs, lseek, local_fd, size, mode);
|
CHECK_AND_CALL(ret, r, vfs, lseek, local_fd, size, mode);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -239,7 +239,7 @@ ssize_t esp_vfs_read(struct _reent *r, int fd, void * dst, size_t size)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int local_fd = translate_fd(vfs, fd);
|
int local_fd = translate_fd(vfs, fd);
|
||||||
int ret;
|
ssize_t ret;
|
||||||
CHECK_AND_CALL(ret, r, vfs, read, local_fd, dst, size);
|
CHECK_AND_CALL(ret, r, vfs, read, local_fd, dst, size);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@@ -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);
|
assert(fd >=0 && fd < 3);
|
||||||
const char *data_c = (const char *)data;
|
const char *data_c = (const char *)data;
|
||||||
|
Reference in New Issue
Block a user