From 971491b5a40bdca607ac31dbb88d5a3e31f55982 Mon Sep 17 00:00:00 2001 From: Luis Ubieda Date: Sun, 28 Apr 2024 17:18:11 -0400 Subject: [PATCH] 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 --- drivers/sensor/default_rtio_sensor.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/sensor/default_rtio_sensor.c b/drivers/sensor/default_rtio_sensor.c index ef63d52c1c..c21736f792 100644 --- a/drivers/sensor/default_rtio_sensor.c +++ b/drivers/sensor/default_rtio_sensor.c @@ -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) {