Skip to content
Snippets Groups Projects
Verified Commit cfe0414b authored by Miroslav Hanak's avatar Miroslav Hanak
Browse files

device_token_state_msg: add input check

to handle possible out of range values of input dt_state enum
parent cb4be529
1 merge request!17Device token improvements
......@@ -19,8 +19,13 @@ const char const *state_messages[] = {
"device_token crc check failed",
};
const char *device_token_state_msg(enum dt_state state){
return state_messages[state];
const char *device_token_state_msg(enum dt_state state) {
switch(state) {
case DT_OK: case DT_UNDEF: case DT_LENGTH: case DT_DECODE: case DT_CRC:
return state_messages[state];
default:
return NULL;
};
}
static uint32_t get_crc(uint8_t *data, unsigned len) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment