In a number of functions in lfs_emubd.c the functions are returning when f.e. fread fails. But this is not closing the file, thus leaking the resource.
Here are all of them (from cppcheck):
[features/storage/filesystem/littlefs/littlefs/emubd/lfs_emubd.c:57]: (error) Resource leak: f
[features/storage/filesystem/littlefs/littlefs/emubd/lfs_emubd.c:99]: (error) Resource leak: f
[features/storage/filesystem/littlefs/littlefs/emubd/lfs_emubd.c:104]: (error) Resource leak: f
[features/storage/filesystem/littlefs/littlefs/emubd/lfs_emubd.c:140]: (error) Resource leak: f
[features/storage/filesystem/littlefs/littlefs/emubd/lfs_emubd.c:145]: (error) Resource leak: f
[features/storage/filesystem/littlefs/littlefs/emubd/lfs_emubd.c:150]: (error) Resource leak: f
[features/storage/filesystem/littlefs/littlefs/emubd/lfs_emubd.c:156]: (error) Resource leak: f
[features/storage/filesystem/littlefs/littlefs/emubd/lfs_emubd.c:217]: (error) Resource leak: f
[features/storage/filesystem/littlefs/littlefs/emubd/lfs_emubd.c:233]: (error) Resource leak: f
@geky
[ ] Question
[ ] Enhancement
[X] Bug
Internal Jira reference: https://jira.arm.com/browse/MBOCUSTRIA-967
cc @ARMmbed/mbed-os-storage
Shouldn't this issue be placed on that repository?
ARMmbed/littlefs
@geky
I'm going to be honest, this low priority right now. emubd is used primarily for testing, and when it errors, it errors.
If you're using emubd for real applications, it would likely be a better idea to map littlefs to a real disk/file. For example: https://github.com/ARMmbed/littlefs-fuse/blob/master/lfs_fuse_bd.c
I've moved this over here https://github.com/ARMmbed/littlefs/issues/260 so it's still tracked and can be taken off your guys's backlog.
Closed as being tracked in the upstream repository where it should be fixed.