testing: Fix undefined behavior with logging

In some cases a random byte pattern was interpreted as a
boolean type. This happend when the conversion to a bool
was not successful but its value was logged anyway.
This commit is contained in:
Lukas Woodtli 2023-11-21 13:21:30 +01:00 committed by mlasch
parent 33ecee2fe2
commit dd586168cf

View File

@ -577,7 +577,7 @@ int lwm2m_data_decode_bool(const lwm2m_data_t * dataP,
break;
}
LOG_ARG("result: %d, value: %s", result, *valueP ? "true" : "false");
LOG_ARG("result: %d, value: %s", result, result == 0 ? "undef" : (*valueP ? "true" : "false"));
return result;
}