From 2dabb149652dd8bba90e0a082267fffbebb4b14a Mon Sep 17 00:00:00 2001 From: Gopalkrishna N Biradar Date: Wed, 30 Oct 2024 17:40:21 +0530 Subject: [PATCH 1/3] fix: Skip mkdir for FatFS root in settings API Signed-off-by: Gopalkrishna N Biradar --- subsys/settings/src/settings_file.c | 40 +++++++++++++++++------------ 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/subsys/settings/src/settings_file.c b/subsys/settings/src/settings_file.c index 43dcd1004f580..b841c805083dc 100644 --- a/subsys/settings/src/settings_file.c +++ b/subsys/settings/src/settings_file.c @@ -532,25 +532,31 @@ static int mkdir_if_not_exists(const char *path) static int mkdir_for_file(const char *file_path) { - char dir_path[SETTINGS_FILE_NAME_MAX]; - int err; - - for (size_t i = 0; file_path[i] != '\0'; i++) { - if (i > 0 && file_path[i] == '/') { - dir_path[i] = '\0'; - - err = mkdir_if_not_exists(dir_path); - if (err) { - return err; - } - } - - dir_path[i] = file_path[i]; - } - - return 0; + char dir_path[SETTINGS_FILE_NAME_MAX]; + int err; + + for (size_t i = 0; file_path[i] != '\0'; i++) { + if (i > 0 && file_path[i] == '/') { + dir_path[i] = '\0'; + + // Skip mkdir for FatFS root directories (ending with ':') + if (strrchr(dir_path, ':') == &dir_path[strlen(dir_path) - 1]) { + LOG_DBG("FatFS root directory detected, skipping mkdir for path: %s", + dir_path); + } else { + err = mkdir_if_not_exists(dir_path); + if (err) { + return err; + } + } + } + dir_path[i] = file_path[i]; + } + + return 0; } + int settings_backend_init(void) { static struct settings_file config_init_settings_file = { From 6ae364855307c67410b993f0e0eaa0ae25afff70 Mon Sep 17 00:00:00 2001 From: Gopalkrishna N Biradar Date: Wed, 6 Nov 2024 12:55:43 +0530 Subject: [PATCH 2/3] fix: UC2, clang-format, git action Signed-off-by: Gopalkrishna N Biradar --- subsys/settings/src/settings_file.c | 44 ++++++++++++++--------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/subsys/settings/src/settings_file.c b/subsys/settings/src/settings_file.c index b841c805083dc..1f4bd18bad4ef 100644 --- a/subsys/settings/src/settings_file.c +++ b/subsys/settings/src/settings_file.c @@ -532,28 +532,28 @@ static int mkdir_if_not_exists(const char *path) static int mkdir_for_file(const char *file_path) { - char dir_path[SETTINGS_FILE_NAME_MAX]; - int err; - - for (size_t i = 0; file_path[i] != '\0'; i++) { - if (i > 0 && file_path[i] == '/') { - dir_path[i] = '\0'; - - // Skip mkdir for FatFS root directories (ending with ':') - if (strrchr(dir_path, ':') == &dir_path[strlen(dir_path) - 1]) { - LOG_DBG("FatFS root directory detected, skipping mkdir for path: %s", - dir_path); - } else { - err = mkdir_if_not_exists(dir_path); - if (err) { - return err; - } - } - } - dir_path[i] = file_path[i]; - } - - return 0; + char dir_path[SETTINGS_FILE_NAME_MAX]; + int err; + + for (size_t i = 0; file_path[i] != '\0'; i++) { + if (i > 0 && file_path[i] == '/') { + dir_path[i] = '\0'; + + /* Skip mkdir for FatFS root directories (ending with ':') */ + if (strrchr(dir_path, ':') == &dir_path[strlen(dir_path) - 1]) { + LOG_DBG("FatFS root directory detected, skipping mkdir for path: " + "%s", dir_path); + } else { + err = mkdir_if_not_exists(dir_path); + if (err) { + return err; + } + } + } + dir_path[i] = file_path[i]; + } + + return 0; } From 6338a4f62b9f08f33daa24539f1e3cb3200c9df7 Mon Sep 17 00:00:00 2001 From: Gopalkrishnbiradar <149266565+Gopalkrishnbiradar@users.noreply.github.com> Date: Fri, 6 Dec 2024 15:06:09 +0000 Subject: [PATCH 3/3] Update settings_file.c update the clang format --- subsys/settings/src/settings_file.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/subsys/settings/src/settings_file.c b/subsys/settings/src/settings_file.c index 1f4bd18bad4ef..a056e969fb911 100644 --- a/subsys/settings/src/settings_file.c +++ b/subsys/settings/src/settings_file.c @@ -541,8 +541,7 @@ static int mkdir_for_file(const char *file_path) /* Skip mkdir for FatFS root directories (ending with ':') */ if (strrchr(dir_path, ':') == &dir_path[strlen(dir_path) - 1]) { - LOG_DBG("FatFS root directory detected, skipping mkdir for path: " - "%s", dir_path); + LOG_DBG("FatFS root directory detected, skipping mkdir for path: ""%s", dir_path); } else { err = mkdir_if_not_exists(dir_path); if (err) {