From 63bb74c69a8092cbc1588096fe255e4e772869a5 Mon Sep 17 00:00:00 2001 From: Fabian Blatz Date: Sun, 20 Aug 2023 19:06:29 +0200 Subject: [PATCH] modules: lvgl: Handle errors on fs_tell Changes the lvgl filesystem `tell()` wrapper to check for errors returned by zephyr filesystem subsystem. Signed-off-by: Fabian Blatz --- modules/lvgl/lvgl_fs.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/lvgl/lvgl_fs.c b/modules/lvgl/lvgl_fs.c index 04747ad4fae970..a05e21748d41a3 100644 --- a/modules/lvgl/lvgl_fs.c +++ b/modules/lvgl/lvgl_fs.c @@ -45,6 +45,9 @@ static lv_fs_res_t errno_to_lv_fs_res(int err) case -EINVAL: /*Invalid parameter among arguments*/ return LV_FS_RES_INV_PARAM; + case -ENOTSUP: + /*Not supported by the filesystem*/ + return LV_FS_RES_NOT_IMP; default: return LV_FS_RES_UNKNOWN; } @@ -153,7 +156,14 @@ static lv_fs_res_t lvgl_fs_seek(struct _lv_fs_drv_t *drv, void *file, uint32_t p static lv_fs_res_t lvgl_fs_tell(struct _lv_fs_drv_t *drv, void *file, uint32_t *pos_p) { - *pos_p = fs_tell((struct fs_file_t *)file); + off_t pos; + + pos = fs_tell((struct fs_file_t *)file); + if (pos < 0) { + return errno_to_lv_fs_res(pos); + } + + *pos_p = pos; return LV_FS_RES_OK; }