Skip to content

Commit

Permalink
feat(fsdrv): add posix lseek() error checking (#3444)
Browse files Browse the repository at this point in the history
Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com>
  • Loading branch information
2 people authored and kisvegabor committed Sep 20, 2022
1 parent 3026af5 commit 7aa1cc6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/extra/libs/fsdrv/lv_fs_posix.c
Expand Up @@ -176,8 +176,8 @@ static lv_fs_res_t fs_write(lv_fs_drv_t * drv, void * file_p, const void * buf,
static lv_fs_res_t fs_seek(lv_fs_drv_t * drv, void * file_p, uint32_t pos, lv_fs_whence_t whence)
{
LV_UNUSED(drv);
lseek((lv_uintptr_t)file_p, pos, whence);
return LV_FS_RES_OK;
off_t offset = lseek((lv_uintptr_t)file_p, pos, whence);
return offset < 0 ? LV_FS_RES_FS_ERR : LV_FS_RES_OK;
}

/**
Expand All @@ -191,8 +191,9 @@ static lv_fs_res_t fs_seek(lv_fs_drv_t * drv, void * file_p, uint32_t pos, lv_fs
static lv_fs_res_t fs_tell(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p)
{
LV_UNUSED(drv);
*pos_p = lseek((lv_uintptr_t)file_p, 0, SEEK_CUR);
return LV_FS_RES_OK;
off_t offset = lseek((lv_uintptr_t)file_p, 0, SEEK_CUR);
*pos_p = offset;
return offset < 0 ? LV_FS_RES_FS_ERR : LV_FS_RES_OK;
}

#ifdef WIN32
Expand Down

0 comments on commit 7aa1cc6

Please sign in to comment.