Cope with padding inside ZoneOptionValueTyped

As it seems, ZoneOptionValueEnum is optimised by ARM-GCC to have only 8bits, rather than the 32bits used by the host compiler. Meaning that with "data" pointing at ZoneOptionValueTyped::value, we need the offset and not the size of the element before to properly rewind the data pointer.
This commit is contained in:
Raphael Coeffic
2021-11-10 11:07:03 +01:00
parent bcdb9bd311
commit 455cb1c2b8
@@ -166,7 +166,7 @@ bool w_vbat_max(const YamlNode* node, uint32_t val, yaml_writer_func wf, void* o
uint8_t select_zov(void* user, uint8_t* data, uint32_t bitoffs)
{
data += bitoffs >> 3UL;
data -= sizeof(ZoneOptionValueEnum);
data -= offsetof(ZoneOptionValueTyped, value);
ZoneOptionValueEnum* p_zovt = (ZoneOptionValueEnum*)data;
if (*p_zovt > ZOV_Color) return 0;
return *p_zovt;