diff mbox series

[uclibc-ng-devel] Cast to proper types inside atomic macro.

Message ID 20240519094727.950755-1-dm.chestnykh@gmail.com
State Superseded
Headers show
Series [uclibc-ng-devel] Cast to proper types inside atomic macro. | expand

Commit Message

Dmitry Chestnykh May 19, 2024, 9:47 a.m. UTC
GCC-14 raises `-Wint-conversion` error
if lvalues are of pointer types and rvalues
are of integer types.

Signed-off-by: Dmitry Chestnykh <dm.chestnykh@gmail.com>
---
 include/atomic.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/include/atomic.h b/include/atomic.h
index 267aff5d5..2ed9b9b65 100644
--- a/include/atomic.h
+++ b/include/atomic.h
@@ -54,15 +54,15 @@ 
    and following args.  */
 #define __atomic_val_bysize(pre, post, mem, ...)			      \
   ({									      \
-    __typeof (*mem) __atg1_result;					      \
+    __typeof ((__typeof (*(mem))) *(mem)) __atg1_result;					      \
     if (sizeof (*mem) == 1)						      \
-      __atg1_result = pre##_8_##post (mem, __VA_ARGS__);		      \
+      __atg1_result = (__typeof ((__typeof (*(mem))) *(mem))) pre##_8_##post (mem, __VA_ARGS__);		      \
     else if (sizeof (*mem) == 2)					      \
-      __atg1_result = pre##_16_##post (mem, __VA_ARGS__);		      \
+      __atg1_result = (__typeof ((__typeof (*(mem))) *(mem))) pre##_16_##post (mem, __VA_ARGS__);		      \
     else if (sizeof (*mem) == 4)					      \
-      __atg1_result = pre##_32_##post (mem, __VA_ARGS__);		      \
+      __atg1_result = (__typeof ((__typeof (*(mem))) *(mem))) pre##_32_##post (mem, __VA_ARGS__);		      \
     else if (sizeof (*mem) == 8)					      \
-      __atg1_result = pre##_64_##post (mem, __VA_ARGS__);		      \
+      __atg1_result = (__typeof ((__typeof (*(mem))) *(mem))) pre##_64_##post (mem, __VA_ARGS__);		      \
     else								      \
       abort ();								      \
     __atg1_result;							      \