From 97a19517ffe3438562f80c314f5b6f3f27df7668 Mon Sep 17 00:00:00 2001 From: Aurelien DARRAGON Date: Wed, 19 Feb 2025 11:42:04 +0100 Subject: [PATCH] MINOR: clock: always use atomic ops for global_now_ms global_now_ms is shared between threads so we must give hint to the compiler that read/writes operations should be performed atomically. Everywhere global_now_ms was used, atomic ops were used, except in clock_update_global_date() where a read was performed without using atomic op. In practise it is not an issue because on most systems such reads should be atomic already, but to prevent any confusion or potential bug on exotic systems, let's use an explicit _HA_ATOMIC_LOAD there. This may be backported up to 2.8 --- src/clock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/clock.c b/src/clock.c index 1a6a80be0..5a264146d 100644 --- a/src/clock.c +++ b/src/clock.c @@ -270,7 +270,7 @@ void clock_update_global_date() * otherwise catch up. */ old_now_ns = _HA_ATOMIC_LOAD(&global_now_ns); - old_now_ms = global_now_ms; + old_now_ms = _HA_ATOMIC_LOAD(&global_now_ms); do { if (now_ns < old_now_ns)