We do not actually need strlen here at all, just checking the first byte
for '0' is enough as strlen was only compared to 0.
This fixes the following warning:
In function ‘do_save_state’,
inlined from ‘save_state’ at core/state.c:57:10:
core/state.c:26:13: warning: ‘strnlen’ specified bound 16 exceeds source size 5 [-Wstringop-overread]
26 | if (strnlen(v, BOOTLOADER_VAR_LENGTH) == 0) { \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
core/state.c:35:9: note: in expansion of macro ‘CHECK_STATE_VAR’
35 | CHECK_STATE_VAR(key);
| ^~~~~~~~~~~~~~~
In function ‘read_state’,
inlined from ‘do_get_state’ at core/state.c:81:25,
inlined from ‘get_state’ at core/state.c:113:10:
core/state.c:26:13: warning: ‘strnlen’ specified bound 16 exceeds source size 5 [-Wstringop-overread]
26 | if (strnlen(v, BOOTLOADER_VAR_LENGTH) == 0) { \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
core/state.c:63:9: note: in expansion of macro ‘CHECK_STATE_VAR’
63 | CHECK_STATE_VAR(key);
| ^~~~~~~~~~~~~~~
Signed-off-by: Dominique Martinet <
dominique...@atmark-techno.com>
---
core/state.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/core/state.c b/core/state.c
index 2ec01f5d73ef..27481971a232 100644
--- a/core/state.c
+++ b/core/state.c
@@ -23,7 +23,7 @@
* environment/
*/
#define CHECK_STATE_VAR(v) do { \
- if (strnlen(v, BOOTLOADER_VAR_LENGTH) == 0) { \
+ if (v[0] == 0) { \
WARN("Update Status Storage Key " \
"is empty, setting it to 'ustate'"); \
v = (char *)"ustate"; \
--
2.35.1