Skip to content

patches: littlefs2 properly init class variables #1059

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions patches/0262-littlefs2-Properly-init-class-variables-451.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
From d17add6c12783ea59d40cf9d4a9dfe0e558471b6 Mon Sep 17 00:00:00 2001
From: Jamie Smith <[email protected]>
Date: Thu, 17 Apr 2025 00:37:26 -0700
Subject: [PATCH] littlefs2: Properly init class variables (#451)

* littlefs2: Properly init class variables

* Style fix
---
.../littlefsv2/include/littlefsv2/LittleFileSystem2.h | 6 +++---
storage/filesystem/littlefsv2/source/LittleFileSystem2.cpp | 1 -
2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/storage/filesystem/littlefsv2/include/littlefsv2/LittleFileSystem2.h b/storage/filesystem/littlefsv2/include/littlefsv2/LittleFileSystem2.h
index d753b3fb11..0d13ef7fb5 100644
--- a/storage/filesystem/littlefsv2/include/littlefsv2/LittleFileSystem2.h
+++ b/storage/filesystem/littlefsv2/include/littlefsv2/LittleFileSystem2.h
@@ -289,9 +289,9 @@ protected:
#endif //!(DOXYGEN_ONLY)

private:
- lfs2_t _lfs; // The actual file system
- struct lfs2_config _config;
- mbed::BlockDevice *_bd; // The block device
+ lfs2_t _lfs{}; // The actual file system
+ struct lfs2_config _config {};
+ mbed::BlockDevice *_bd = nullptr; // The block device

// thread-safe locking
PlatformMutex _mutex;
diff --git a/storage/filesystem/littlefsv2/source/LittleFileSystem2.cpp b/storage/filesystem/littlefsv2/source/LittleFileSystem2.cpp
index ea270a48d3..f5ac519e0b 100644
--- a/storage/filesystem/littlefsv2/source/LittleFileSystem2.cpp
+++ b/storage/filesystem/littlefsv2/source/LittleFileSystem2.cpp
@@ -149,7 +149,6 @@ LittleFileSystem2::LittleFileSystem2(const char *name, BlockDevice *bd,
lfs2_size_t cache_size, lfs2_size_t lookahead_size)
: FileSystem(name)
{
- memset(&_config, 0, sizeof(_config));
_config.block_size = block_size;
_config.block_cycles = block_cycles;
_config.cache_size = cache_size;
--
2.47.2