From 4c6bd50e1742189e947bad914169a774ffa2d3b9 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 (cherry picked from commit 97a19517ffe3438562f80c314f5b6f3f27df7668) Signed-off-by: Christopher Faulet (cherry picked from commit e5057a90eb505d3a8f98d655bf669e6943a62861) Signed-off-by: Amaury Denoyelle --- src/clock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/clock.c b/src/clock.c index 08abd82..d2c1215 100644 --- a/src/clock.c +++ b/src/clock.c @@ -259,7 +259,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) -- 1.7.10.4