battery: don't init uint16_t with -1.0f

This was flagged as undefined behaviour by fuzz testing.
This commit is contained in:
Julian Oes 2020-12-07 14:59:10 +13:00 committed by Beat Küng
parent 681590c510
commit fd261b590c
1 changed files with 1 additions and 1 deletions

View File

@ -113,7 +113,7 @@ void Battery::reset()
// TODO: check if it is sane to reset warning to NONE
_battery_status.warning = battery_status_s::BATTERY_WARNING_NONE;
_battery_status.connected = false;
_battery_status.capacity = _params.capacity;
_battery_status.capacity = _params.capacity > 0.0f ? (uint16_t)_params.capacity : 0;
_battery_status.temperature = NAN;
_battery_status.id = (uint8_t) _index;
}