sysparam_get_bool: memcpy the binary values out.

This commit is contained in:
Our Air Quality 2017-06-06 20:56:32 +10:00 committed by Erwin Boskma
parent d3a8ebb06b
commit 0cab2cb5cc
No known key found for this signature in database
GPG key ID: 1C79B2FD5FD63533

View file

@ -801,9 +801,13 @@ sysparam_status_t sysparam_get_bool(const char *key, bool *result) {
do {
if (binary) {
if (data_len == 1) { // int8 value
*result = (int8_t)(*buf) ? true : false;
uint8_t value;
memcpy(&value, buf, sizeof(value));
*result = value ? true : false;
} else if (data_len == 4) { // int32 value
*result = (int32_t)(*buf) ? true : false;
uint32_t value;
memcpy(&value, buf, sizeof(value));
*result = value ? true : false;
} else {
status = SYSPARAM_PARSEFAILED;
}