The branch main has been updated by markj:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=08b0c98006b6b9f3722df0ce462f6a4aa8ee06f2

commit 08b0c98006b6b9f3722df0ce462f6a4aa8ee06f2
Author:     Mark Johnston <ma...@freebsd.org>
AuthorDate: 2023-02-09 14:54:52 +0000
Commit:     Mark Johnston <ma...@freebsd.org>
CommitDate: 2023-02-09 15:16:34 +0000

    atomic: Fix the atomic_load_ptr() *SAN interceptor
    
    The interceptor didn't handle a pointer of type "foo * const *" and in
    that case we'd get compiler errors 1) an invalid cast to volatile
    uintptr_t, and 2) an assignment to a variable of type "foo * const"
    (__retptr).
    
    Reported by:    mjg
    MFC after:      1 week
---
 sys/sys/atomic_san.h | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/sys/sys/atomic_san.h b/sys/sys/atomic_san.h
index beeea82a666b..3a72cb4b4980 100644
--- a/sys/sys/atomic_san.h
+++ b/sys/sys/atomic_san.h
@@ -267,17 +267,11 @@ ATOMIC_SAN_THREAD_FENCE(SAN_INTERCEPTOR_PREFIX);
 #define        atomic_fcmpset_acq_ptr          ATOMIC_SAN(fcmpset_acq_ptr)
 #define        atomic_fcmpset_rel_ptr          ATOMIC_SAN(fcmpset_rel_ptr)
 #define        atomic_fetchadd_ptr             ATOMIC_SAN(fetchadd_ptr)
-#define        atomic_load_ptr(x)              ({                              
        \
-       __typeof(*x) __retptr;                                                  
\
-       __retptr = (void *)ATOMIC_SAN(load_ptr)((volatile uintptr_t *)(x));     
\
-       __retptr;                                                               
\
-})
+#define        atomic_load_ptr(x)                                              
\
+       ((void *)ATOMIC_SAN(load_ptr)(__DECONST(volatile uintptr_t *, (x))))
 #define        atomic_load_acq_ptr             ATOMIC_SAN(load_acq_ptr)
-#define        atomic_load_consume_ptr(x)      ({                              
        \
-       __typeof(*x) __retptr;                                                  
\
-       __retptr = (void *)atomic_load_acq_ptr((volatile uintptr_t *)(x));\
-       __retptr;                                                               
\
-})
+#define        atomic_load_consume_ptr(x)                                      
\
+       ((void *)atomic_load_acq_ptr((volatile uintptr_t *)(x)))
 #define        atomic_readandclear_ptr         ATOMIC_SAN(readandclear_ptr)
 #define        atomic_set_ptr                  ATOMIC_SAN(set_ptr)
 #define        atomic_set_acq_ptr              ATOMIC_SAN(set_acq_ptr)

Reply via email to