From 111247504f4177c9b9fb887334f23323e7877b59 Mon Sep 17 00:00:00 2001 From: xsider Date: Thu, 2 May 2024 07:20:47 +0200 Subject: [PATCH] Storage: #ifdefs needed, IS_ENABLED(...) does not work at compile time (#44) #ifdefs needed because linker links files which are not compiled when CONFIG_THINGSET_STORAGE_AUTOSAVE=n --- src/storage_common.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/storage_common.c b/src/storage_common.c index 2f458b3..0552af6 100644 --- a/src/storage_common.c +++ b/src/storage_common.c @@ -44,9 +44,9 @@ static void thingset_storage_save_handler(struct k_work *work) LOG_WRN("Data not stored because previous load failed."); } - if (IS_ENABLED(CONFIG_THINGSET_STORAGE_AUTOSAVE)) { - thingset_sdk_reschedule_work(dwork, K_HOURS(CONFIG_THINGSET_STORAGE_AUTOSAVE_INTERVAL)); - } +#ifdef CONFIG_THINGSET_STORAGE_AUTOSAVE + thingset_sdk_reschedule_work(dwork, K_HOURS(CONFIG_THINGSET_STORAGE_AUTOSAVE_INTERVAL)); +#endif } static int thingset_storage_init(void) @@ -72,10 +72,9 @@ static int thingset_storage_init(void) thingset_set_update_callback(&ts, TS_SUBSET_NVM, thingset_storage_update_handler); } - if (IS_ENABLED(CONFIG_THINGSET_STORAGE_AUTOSAVE)) { - thingset_sdk_reschedule_work(&storage_work, - K_HOURS(CONFIG_THINGSET_STORAGE_AUTOSAVE_INTERVAL)); - } +#ifdef CONFIG_THINGSET_STORAGE_AUTOSAVE + thingset_sdk_reschedule_work(&storage_work, K_HOURS(CONFIG_THINGSET_STORAGE_AUTOSAVE_INTERVAL)); +#endif return 0; }