]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
locking/local_lock: s/l/__l/ and s/tl/__tl/ to reduce the risk of shadowing
authorVincent Mailhol <mailhol@kernel.org>
Thu, 27 Nov 2025 14:41:40 +0000 (15:41 +0100)
committerIngo Molnar <mingo@kernel.org>
Mon, 1 Dec 2025 05:56:16 +0000 (06:56 +0100)
The Linux kernel coding style advises to avoid common variable
names in function-like macros to reduce the risk of namespace
collisions.

Throughout local_lock_internal.h, several macros use the rather common
variable names 'l' and 'tl'. This already resulted in an actual
collision: the __local_lock_acquire() function like macro is currently
shadowing the parameter 'l' of the:

  class_##_name##_t class_##_name##_constructor(_type *l)

function factory from <linux/cleanup.h>.

Rename the variable 'l' to '__l' and the variable 'tl' to '__tl'
throughout the file to fix the current namespace collision and
to prevent future ones.

[ bigeasy: Rebase, update all l and tl instances in macros ]

Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Waiman Long <longman@redhat.com>
Link: https://patch.msgid.link/20251127144140.215722-3-bigeasy@linutronix.de
include/linux/local_lock_internal.h

index a4dc479157b5cd63a7e57463b9aba1381e52869e..8f82b4eb542f2e502770e7c145e7af8ae6f5645d 100644 (file)
@@ -99,18 +99,18 @@ do {                                                                \
 
 #define __local_lock_acquire(lock)                                     \
        do {                                                            \
-               local_trylock_t *tl;                                    \
-               local_lock_t *l;                                        \
+               local_trylock_t *__tl;                                  \
+               local_lock_t *__l;                                      \
                                                                        \
-               l = (local_lock_t *)(lock);                             \
-               tl = (local_trylock_t *)l;                              \
+               __l = (local_lock_t *)(lock);                           \
+               __tl = (local_trylock_t *)__l;                          \
                _Generic((lock),                                        \
                        local_trylock_t *: ({                           \
-                               lockdep_assert(tl->acquired == 0);      \
-                               WRITE_ONCE(tl->acquired, 1);            \
+                               lockdep_assert(__tl->acquired == 0);    \
+                               WRITE_ONCE(__tl->acquired, 1);          \
                        }),                                             \
                        local_lock_t *: (void)0);                       \
-               local_lock_acquire(l);                                  \
+               local_lock_acquire(__l);                                \
        } while (0)
 
 #define __local_lock(lock)                                     \
@@ -133,36 +133,36 @@ do {                                                              \
 
 #define __local_trylock(lock)                                  \
        ({                                                      \
-               local_trylock_t *tl;                            \
+               local_trylock_t *__tl;                          \
                                                                \
                preempt_disable();                              \
-               tl = (lock);                                    \
-               if (READ_ONCE(tl->acquired)) {                  \
+               __tl = (lock);                                  \
+               if (READ_ONCE(__tl->acquired)) {                \
                        preempt_enable();                       \
-                       tl = NULL;                              \
+                       __tl = NULL;                            \
                } else {                                        \
-                       WRITE_ONCE(tl->acquired, 1);            \
+                       WRITE_ONCE(__tl->acquired, 1);          \
                        local_trylock_acquire(                  \
-                               (local_lock_t *)tl);            \
+                               (local_lock_t *)__tl);          \
                }                                               \
-               !!tl;                                           \
+               !!__tl;                                         \
        })
 
 #define __local_trylock_irqsave(lock, flags)                   \
        ({                                                      \
-               local_trylock_t *tl;                            \
+               local_trylock_t *__tl;                          \
                                                                \
                local_irq_save(flags);                          \
-               tl = (lock);                                    \
-               if (READ_ONCE(tl->acquired)) {                  \
+               __tl = (lock);                                  \
+               if (READ_ONCE(__tl->acquired)) {                \
                        local_irq_restore(flags);               \
-                       tl = NULL;                              \
+                       __tl = NULL;                            \
                } else {                                        \
-                       WRITE_ONCE(tl->acquired, 1);            \
+                       WRITE_ONCE(__tl->acquired, 1);          \
                        local_trylock_acquire(                  \
-                               (local_lock_t *)tl);            \
+                               (local_lock_t *)__tl);          \
                }                                               \
-               !!tl;                                           \
+               !!__tl;                                         \
        })
 
 /* preemption or migration must be disabled before calling __local_lock_is_locked */
@@ -170,16 +170,16 @@ do {                                                              \
 
 #define __local_lock_release(lock)                                     \
        do {                                                            \
-               local_trylock_t *tl;                                    \
-               local_lock_t *l;                                        \
+               local_trylock_t *__tl;                                  \
+               local_lock_t *__l;                                      \
                                                                        \
-               l = (local_lock_t *)(lock);                             \
-               tl = (local_trylock_t *)l;                              \
-               local_lock_release(l);                                  \
+               __l = (local_lock_t *)(lock);                           \
+               __tl = (local_trylock_t *)__l;                          \
+               local_lock_release(__l);                                \
                _Generic((lock),                                        \
                        local_trylock_t *: ({                           \
-                               lockdep_assert(tl->acquired == 1);      \
-                               WRITE_ONCE(tl->acquired, 0);            \
+                               lockdep_assert(__tl->acquired == 1);    \
+                               WRITE_ONCE(__tl->acquired, 0);          \
                        }),                                             \
                        local_lock_t *: (void)0);                       \
        } while (0)
@@ -223,12 +223,12 @@ typedef spinlock_t local_trylock_t;
 #define INIT_LOCAL_LOCK(lockname) __LOCAL_SPIN_LOCK_UNLOCKED((lockname))
 #define INIT_LOCAL_TRYLOCK(lockname) __LOCAL_SPIN_LOCK_UNLOCKED((lockname))
 
-#define __local_lock_init(l)                                   \
+#define __local_lock_init(__l)                                 \
        do {                                                    \
-               local_spin_lock_init((l));                      \
+               local_spin_lock_init((__l));                    \
        } while (0)
 
-#define __local_trylock_init(l)                        __local_lock_init(l)
+#define __local_trylock_init(__l)                      __local_lock_init(__l)
 
 #define __local_lock(__lock)                                   \
        do {                                                    \