Skip to content

Commit a395f74

Browse files
tomi-fontjukkar
authored andcommitted
[nrf fromlist] secure_storage: its: use %l printf length modifier
Cast the UIDs to unsigned long when they are 32 bits. This allows to use a single %l length modifier instead of the double one for long long. Certain printf implementations only support the former and not the latter length modifier, so this has the advantage to work with them now that the UIDs are 32-bit by default. Signed-off-by: Tomi Fontanilles <[email protected]> Upstream PR #: 94171 (cherry picked from commit 2ce0698)
1 parent 5b4a6eb commit a395f74

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

subsys/secure_storage/src/its/implementation.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,15 @@ static bool keep_stored_entry(secure_storage_its_uid_t uid, size_t data_length,
115115
if (existing_data_len == data_length &&
116116
existing_create_flags == create_flags &&
117117
!memcmp(existing_data, p_data, data_length)) {
118-
LOG_DBG("Not writing entry %u/%llu to storage because its stored data"
119-
" (of length %zu) is identical.", uid.caller_id, uid.uid, data_length);
118+
#ifdef CONFIG_SECURE_STORAGE_64_BIT_UID
119+
LOG_DBG("Not writing entry %u/%#llx to storage because its stored data"
120+
" (of length %zu) is identical.", uid.caller_id,
121+
(unsigned long long)uid.uid, data_length);
122+
#else
123+
LOG_DBG("Not writing entry %u/%#lx to storage because its stored data"
124+
" (of length %zu) is identical.", uid.caller_id,
125+
(unsigned long)uid.uid, data_length);
126+
#endif
120127
*ret = PSA_SUCCESS;
121128
return true;
122129
}

subsys/secure_storage/src/its/store/settings.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,15 @@ void secure_storage_its_store_settings_get_name(
3838
{
3939
int ret;
4040

41+
#ifdef CONFIG_SECURE_STORAGE_64_BIT_UID
4142
ret = snprintf(name, SECURE_STORAGE_ITS_STORE_SETTINGS_NAME_BUF_SIZE,
4243
CONFIG_SECURE_STORAGE_ITS_STORE_SETTINGS_PREFIX "%x/%llx",
4344
uid.caller_id, (unsigned long long)uid.uid);
45+
#else
46+
ret = snprintf(name, SECURE_STORAGE_ITS_STORE_SETTINGS_NAME_BUF_SIZE,
47+
CONFIG_SECURE_STORAGE_ITS_STORE_SETTINGS_PREFIX "%x/%lx",
48+
uid.caller_id, (unsigned long)uid.uid);
49+
#endif
4450
__ASSERT_NO_MSG(ret > 0 && ret < SECURE_STORAGE_ITS_STORE_SETTINGS_NAME_BUF_SIZE);
4551
}
4652

0 commit comments

Comments
 (0)