From e91e144fb6c48e330a79320563e5cdb6b1bae841 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Sat, 22 Oct 2022 21:28:38 +0800 Subject: [PATCH] Fix sensors/hyt271.c:811:16: error: 'data.data' may be used uninitialized [-Werror=maybe-uninitialized] Signed-off-by: Xiang Xiao --- drivers/sensors/hyt271.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/sensors/hyt271.c b/drivers/sensors/hyt271.c index baa1339403..cf82cf40ea 100644 --- a/drivers/sensors/hyt271.c +++ b/drivers/sensors/hyt271.c @@ -782,11 +782,11 @@ static int hyt271_thread(int argc, char** argv) { FAR struct hyt271_dev_s *priv = (FAR struct hyt271_dev_s *) ((uintptr_t)strtoul(argv[1], NULL, 0)); + uint32_t orawdata = 0; while (true) { int ret; - uint32_t orawdata; struct hyt271_sensor_data_s data; struct hyt271_sensor_s *hsensor = &priv->sensor[HYT271_SENSOR_HUMI]; struct hyt271_sensor_s *tsensor = &priv->sensor[HYT271_SENSOR_TEMP]; @@ -806,12 +806,7 @@ static int hyt271_thread(int argc, char** argv) } } - /* Store the last sensor data for later comparison */ - - orawdata = data.data; - ret = hyt271_measure_read(priv, &data); - if (!ret) { /* Notify upper */ @@ -838,6 +833,10 @@ static int hyt271_thread(int argc, char** argv) { priv->initial_read = true; } + + /* Store the last sensor data for later comparison */ + + orawdata = data.data; } /* Sleeping thread before fetching the next sensor data */