Skip to content

Commit

Permalink
Merge pull request #11179 from ARMmbed/storage_coverity_fixes
Browse files Browse the repository at this point in the history
Zero initialise all NVStore&kvstore members
  • Loading branch information
Seppo Takalo authored Aug 7, 2019
2 parents 3b0053c + a5e3336 commit 9bf85ef
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion features/storage/kvstore/kv_map/KVMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,5 +332,5 @@ FileSystem *KVMap::get_external_filesystem_instance(const char *name)
return ret != MBED_SUCCESS ? NULL : kv_config->external_fs;
}

}
} // namespace mbed

4 changes: 3 additions & 1 deletion features/storage/kvstore/tdbstore/TDBStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions features/storage/nvstore/source/nvstore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down

0 comments on commit 9bf85ef

Please sign in to comment.