[Concept,15/15] ext4l: Fix cmpxchg macro warning with clang

Message ID 20251230234134.906477-16-sjg@u-boot.org
State New
Headers
Series ext4l: Infrastructure and fixes for write support (part K) |

Commit Message

Simon Glass Dec. 30, 2025, 11:41 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Rename local variables in cmpxchg macro to avoid shadowing when used
inside try_cmpxchg, which also declares __old. Clang complains about
"variable '__old' is uninitialised when used within its own
initialisation" due to the nested macro expansion.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 fs/ext4l/ext4_uboot.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
  

Patch

diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h
index 2d0e817be40..087d8394ab6 100644
--- a/fs/ext4l/ext4_uboot.h
+++ b/fs/ext4l/ext4_uboot.h
@@ -101,12 +101,12 @@  struct timespec64 {
 
 /* cmpxchg - compare and exchange, single-threaded version */
 #define cmpxchg(ptr, old, new) ({		\
-	typeof(*(ptr)) __old = (old);		\
-	typeof(*(ptr)) __new = (new);		\
-	typeof(*(ptr)) __ret = *(ptr);		\
-	if (__ret == __old)			\
-		*(ptr) = __new;			\
-	__ret;					\
+	typeof(*(ptr)) __cmpxchg_old = (old);	\
+	typeof(*(ptr)) __cmpxchg_new = (new);	\
+	typeof(*(ptr)) __cmpxchg_ret = *(ptr);	\
+	if (__cmpxchg_ret == __cmpxchg_old)	\
+		*(ptr) = __cmpxchg_new;		\
+	__cmpxchg_ret;				\
 })
 
 /* Reference count type */