Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Jan 2025 18:17:44 GMT
From:      Olivier Certner <olce@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 176599b58779 - stable/13 - atomic: Avoid casting the return value of atomic_load_ptr to void *
Message-ID:  <202501271817.50RIHijt092269@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by olce:

URL: https://cgit.FreeBSD.org/src/commit/?id=176599b58779b0062b50a5813654eefa5ec78869

commit 176599b58779b0062b50a5813654eefa5ec78869
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-08-28 18:51:06 +0000
Commit:     Olivier Certner <olce@FreeBSD.org>
CommitDate: 2025-01-27 18:17:11 +0000

    atomic: Avoid casting the return value of atomic_load_ptr to void *
    
    Otherwise a cast is needed to load a uintptr_t value.
    
    Fixes:  e1f4d623779d ("rangelocks: remove unneeded cast of the atomic_load_ptr() result")
    MFC after:      1 week
    
    (cherry picked from commit c7a7e997d25d0b33769252d002b16839c864c83d)
---
 sys/sys/atomic_san.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/sys/atomic_san.h b/sys/sys/atomic_san.h
index 22a8faa9e24e..4d503e22dcd2 100644
--- a/sys/sys/atomic_san.h
+++ b/sys/sys/atomic_san.h
@@ -266,7 +266,8 @@ ATOMIC_SAN_THREAD_FENCE(SAN_INTERCEPTOR_PREFIX);
 #define	atomic_fcmpset_rel_ptr		ATOMIC_SAN(fcmpset_rel_ptr)
 #define	atomic_fetchadd_ptr		ATOMIC_SAN(fetchadd_ptr)
 #define	atomic_load_ptr(x)						\
-	((void *)ATOMIC_SAN(load_ptr)(__DECONST(volatile uintptr_t *, (x))))
+	((__typeof(*x))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)					\
 	((void *)atomic_load_acq_ptr((volatile uintptr_t *)(x)))



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202501271817.50RIHijt092269>