From a5e3336c19d84df6df22cf80a9d2bcc0beb9702b Mon Sep 17 00:00:00 2001 From: Seppo Takalo Date: Wed, 31 Jul 2019 15:35:49 +0300 Subject: [PATCH] Zero initialise all NVStore&kvstore members --- features/storage/kvstore/kv_map/KVMap.cpp | 2 +- features/storage/kvstore/tdbstore/TDBStore.cpp | 4 +++- features/storage/nvstore/source/nvstore.cpp | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/features/storage/kvstore/kv_map/KVMap.cpp b/features/storage/kvstore/kv_map/KVMap.cpp index 5bcf7fd6083..45ce0daa4db 100644 --- a/features/storage/kvstore/kv_map/KVMap.cpp +++ b/features/storage/kvstore/kv_map/KVMap.cpp @@ -332,5 +332,5 @@ FileSystem *KVMap::get_external_filesystem_instance(const char *name) return ret != MBED_SUCCESS ? NULL : kv_config->external_fs; } -} +} // namespace mbed diff --git a/features/storage/kvstore/tdbstore/TDBStore.cpp b/features/storage/kvstore/tdbstore/TDBStore.cpp index d82aa556ad1..eda5867e20d 100644 --- a/features/storage/kvstore/tdbstore/TDBStore.cpp +++ b/features/storage/kvstore/tdbstore/TDBStore.cpp @@ -126,7 +126,7 @@ static uint32_t calc_crc(uint32_t init_crc, uint32_t data_size, const void *data TDBStore::TDBStore(BlockDevice *bd) : _ram_table(0), _max_keys(0), _num_keys(0), _bd(bd), _buff_bd(0), _free_space_offset(0), _master_record_offset(0), _master_record_size(0), _is_initialized(false), _active_area(0), _active_area_version(0), _size(0), - _prog_size(0), _work_buf(0), _key_buf(0), _variant_bd_erase_unit_size(false), _inc_set_handle(0) + _area_params{}, _prog_size(0), _work_buf(0), _key_buf(0), _variant_bd_erase_unit_size(false), _inc_set_handle(0) { for (int i = 0; i < _num_areas; i++) { _area_params[i] = { 0 }; @@ -419,6 +419,8 @@ int TDBStore::set_start(set_handle_t *handle, const char *key, size_t final_data // in the upper layers). ih->bd_base_offset = _master_record_offset; ih->new_key = false; + ram_table_ind = 0; + hash = 0; } else { _mutex.lock(); diff --git a/features/storage/nvstore/source/nvstore.cpp b/features/storage/nvstore/source/nvstore.cpp index 320af6bcdeb..7ebb4a9d471 100644 --- a/features/storage/nvstore/source/nvstore.cpp +++ b/features/storage/nvstore/source/nvstore.cpp @@ -145,8 +145,8 @@ static uint32_t crc32(uint32_t init_crc, uint32_t data_size, uint8_t *data_buf) } NVStore::NVStore() : _init_done(0), _init_attempts(0), _active_area(0), _max_keys(NVSTORE_MAX_KEYS), - _active_area_version(0), _free_space_offset(0), _size(0), _mutex(0), _offset_by_key(0), _flash(0), - _min_prog_size(0), _page_buf(0) + _active_area_version(0), _free_space_offset(0), _size(0), _mutex(0), _offset_by_key(0), _flash_area_params{}, + _flash(0), _min_prog_size(0), _page_buf(0) { for (int i = 0; i < NVSTORE_NUM_AREAS; i++) { _flash_area_params[i] = { 0 };