This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit c54bf8b87f42877acd5035091c2e9fce3aedbee2
Author: ouyangxiangzhen <[email protected]>
AuthorDate: Wed Apr 1 19:56:12 2026 +0800

    sched/hrtimer: Fix -Werror=strict-aliasing
    
    This commit fixed strict-aliasing warnings.
    
    Assisted-By: mimo-v2.6-pro
    Signed-off-by: ouyangxiangzhen <[email protected]>
---
 sched/hrtimer/hrtimer.h | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/sched/hrtimer/hrtimer.h b/sched/hrtimer/hrtimer.h
index 312256c0a58..752f64465f5 100644
--- a/sched/hrtimer/hrtimer.h
+++ b/sched/hrtimer/hrtimer.h
@@ -383,13 +383,13 @@ uint32_t hrtimer_read_32(FAR const uint32_t *ptr)
 }
 #endif
 
-/* Generic function to read the value in the queue atomically. */
+/* Generic function to read the pointer in the queue atomically. */
 
-#define hrtimer_read(ptr) \
-  (sizeof(*(ptr)) == 8u ? \
-   hrtimer_read_64((FAR const uint64_t *)(ptr)) : \
-   (sizeof(*(ptr)) == 4u ? \
-    hrtimer_read_32((FAR const uint32_t *)(ptr)) : 0u))
+#if UINTPTR_MAX <= UINT32_MAX
+#  define hrtimer_read_ptr(ptr) hrtimer_read_32((FAR const uint32_t *)(ptr))
+#else
+#  define hrtimer_read_ptr(ptr) hrtimer_read_64((FAR const uint64_t *)(ptr))
+#endif
 
 /****************************************************************************
  * Name: hrtimer_mark_running
@@ -434,7 +434,7 @@ uint32_t hrtimer_read_32(FAR const uint32_t *ptr)
 
 #ifdef CONFIG_SMP
 #  define hrtimer_is_running(timer, cpu) \
-  (hrtimer_read(&g_hrtimer_running[cpu]) == (uintptr_t)(timer))
+  (hrtimer_read_ptr(&g_hrtimer_running[cpu]) == (uintptr_t)(timer))
 #else
 #  define hrtimer_is_running(timer, cpu) (true)
 #endif

Reply via email to