sensor: decoder: Use helper API to compute header size

To be consistent with the computed offset on sensor_submit_fallback()
implementation. This prevents falling in misalignment issues when the
number of sensor channels changes.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
This commit is contained in:
Luis Ubieda 2024-04-28 17:18:11 -04:00 committed by David Leach
parent 45ae829791
commit 971491b5a4

View file

@ -474,9 +474,7 @@ static int decode(const uint8_t *buffer, enum sensor_channel channel, size_t cha
{
const struct sensor_data_generic_header *header =
(const struct sensor_data_generic_header *)buffer;
const q31_t *q =
(const q31_t *)(buffer + sizeof(struct sensor_data_generic_header) +
header->num_channels * sizeof(enum sensor_channel));
const q31_t *q = (const q31_t *)(buffer + compute_header_size(header->num_channels));
int count = 0;
if (*fit != 0 || max_count < 1) {