From 6d2647fd5f857c9e1fc8d43fa74259ea530e5cfc Mon Sep 17 00:00:00 2001 From: stefanbode Date: Thu, 15 Aug 2024 14:28:10 +0200 Subject: [PATCH] fix potential overflow on uptime 2nd try (#21966) * fix potential overflow * fix potential overflow * fix overflow on millis() * fix overflow on millis() * Update xdrv_27_shutter.ino --------- Co-authored-by: Theo Arends <11044339+arendst@users.noreply.github.com> --- tasmota/tasmota_xdrv_driver/xdrv_27_esp32_shutter.ino | 3 ++- tasmota/tasmota_xdrv_driver/xdrv_27_shutter.ino | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_27_esp32_shutter.ino b/tasmota/tasmota_xdrv_driver/xdrv_27_esp32_shutter.ino index d15bf81e9..1841098f0 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_27_esp32_shutter.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_27_esp32_shutter.ino @@ -1383,7 +1383,8 @@ void ShutterUpdateVelocity(uint8_t i) void ShutterWaitForMotorStart(uint8_t i) { - while (millis() < Shutter[i].last_stop_time + ShutterSettings.shutter_motorstop) { + uint32_t start_time = Shutter[i].last_stop_time; + while (TimePassedSince(start_time) < ShutterSettings.shutter_motorstop && TimePassedSince(start_time) > 0) { loop(); } //AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Stoptime done")); diff --git a/tasmota/tasmota_xdrv_driver/xdrv_27_shutter.ino b/tasmota/tasmota_xdrv_driver/xdrv_27_shutter.ino index 6ad2ed327..9209516ac 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_27_shutter.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_27_shutter.ino @@ -654,7 +654,8 @@ void ShutterWaitForMotorStop(uint8_t i) void ShutterWaitForMotorStart(uint8_t i) { - while (millis() < Shutter[i].last_stop_time + Settings->shutter_motorstop) { + uint32_t start_time = Shutter[i].last_stop_time; + while (TimePassedSince(start_time) < Settings->shutter_motorstop && TimePassedSince(start_time) > 0) { loop(); } //AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Stoptime done"));