@@ -48,12 +48,22 @@ const uint8_t base64_coding_table[] = {
48
48
' 4' , ' 5' , ' 6' , ' 7' , ' 8' , ' 9' , ' +' , ' -'
49
49
};
50
50
51
-
51
+ /*
52
+ * \brief Get default KVStore instance for internal flesh storage
53
+ *
54
+ * \return valid pointer to KVStore
55
+ */
52
56
static KVStore *get_kvstore_instance (void )
53
57
{
54
58
KVMap &kv_map = KVMap::get_instance ();
55
59
56
- return kv_map.get_main_kv_instance (STR_EXPAND (MBED_CONF_STORAGE_DEFAULT_KV));
60
+ KVStore *kvstore = kv_map.get_internal_kv_instance (STR_EXPAND (MBED_CONF_STORAGE_DEFAULT_KV));
61
+ if (!kvstore) {
62
+ // Can only happen due to system misconfiguration.
63
+ // Thus considered as unrecoverable error for runtime.
64
+ error (" Failed getting kvstore instance\n " );
65
+ }
66
+ return kvstore;
57
67
}
58
68
59
69
static void generate_fn (char *tdb_filename, uint32_t tdb_file_len, uint32_t uid, uint32_t pid)
@@ -91,9 +101,7 @@ static void generate_fn(char *tdb_filename, uint32_t tdb_file_len, uint32_t uid,
91
101
psa_its_status_t psa_its_set_impl (uint32_t pid, uint32_t uid, uint32_t data_length, const void *p_data, psa_its_create_flags_t create_flags)
92
102
{
93
103
KVStore *kvstore = get_kvstore_instance ();
94
- if (!kvstore) {
95
- error (" psa_its_set_impl() - Failed getting kvstore instance\n " );
96
- }
104
+ MBED_ASSERT (kvstore);
97
105
98
106
if ((create_flags != 0 ) && (create_flags != PSA_ITS_WRITE_ONCE_FLAG)) {
99
107
return PSA_ITS_ERROR_FLAGS_NOT_SUPPORTED;
@@ -130,9 +138,7 @@ psa_its_status_t psa_its_set_impl(uint32_t pid, uint32_t uid, uint32_t data_leng
130
138
psa_its_status_t psa_its_get_impl (uint32_t pid, uint32_t uid, uint32_t data_offset, uint32_t data_length, void *p_data)
131
139
{
132
140
KVStore *kvstore = get_kvstore_instance ();
133
- if (!kvstore) {
134
- error (" psa_its_get_impl() - Failed getting kvstore instance\n " );
135
- }
141
+ MBED_ASSERT (kvstore);
136
142
137
143
// Generate KVStore key
138
144
char kv_key[PSA_ITS_FILENAME_MAX_LEN] = {' \0 ' };
@@ -190,9 +196,7 @@ psa_its_status_t psa_its_get_impl(uint32_t pid, uint32_t uid, uint32_t data_offs
190
196
psa_its_status_t psa_its_get_info_impl (uint32_t pid, uint32_t uid, struct psa_its_info_t *p_info)
191
197
{
192
198
KVStore *kvstore = get_kvstore_instance ();
193
- if (!kvstore) {
194
- error (" psa_its_get_info_impl() - Failed getting kvstore instance\n " );
195
- }
199
+ MBED_ASSERT (kvstore);
196
200
197
201
// Generate KVStore key
198
202
char kv_key[PSA_ITS_FILENAME_MAX_LEN] = {' \0 ' };
@@ -226,9 +230,7 @@ psa_its_status_t psa_its_get_info_impl(uint32_t pid, uint32_t uid, struct psa_it
226
230
psa_its_status_t psa_its_remove_impl (uint32_t pid, uint32_t uid)
227
231
{
228
232
KVStore *kvstore = get_kvstore_instance ();
229
- if (!kvstore) {
230
- error (" psa_its_remove_impl() - Failed getting kvstore instance\n " );
231
- }
233
+ MBED_ASSERT (kvstore);
232
234
233
235
// Generate KVStore key
234
236
char kv_key[PSA_ITS_FILENAME_MAX_LEN] = {' \0 ' };
0 commit comments