Skip to content

Commit 719e357

Browse files
vincent-mailholingomolnar
authored andcommitted
locking/local_lock: s/l/__l/ and s/tl/__tl/ to reduce the risk of shadowing
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
1 parent 52ed746 commit 719e357

1 file changed

Lines changed: 31 additions & 31 deletions

File tree

include/linux/local_lock_internal.h

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -99,18 +99,18 @@ do { \
9999

100100
#define __local_lock_acquire(lock) \
101101
do { \
102-
local_trylock_t *tl; \
103-
local_lock_t *l; \
102+
local_trylock_t *__tl; \
103+
local_lock_t *__l; \
104104
\
105-
l = (local_lock_t *)(lock); \
106-
tl = (local_trylock_t *)l; \
105+
__l = (local_lock_t *)(lock); \
106+
__tl = (local_trylock_t *)__l; \
107107
_Generic((lock), \
108108
local_trylock_t *: ({ \
109-
lockdep_assert(tl->acquired == 0); \
110-
WRITE_ONCE(tl->acquired, 1); \
109+
lockdep_assert(__tl->acquired == 0); \
110+
WRITE_ONCE(__tl->acquired, 1); \
111111
}), \
112112
local_lock_t *: (void)0); \
113-
local_lock_acquire(l); \
113+
local_lock_acquire(__l); \
114114
} while (0)
115115

116116
#define __local_lock(lock) \
@@ -133,53 +133,53 @@ do { \
133133

134134
#define __local_trylock(lock) \
135135
({ \
136-
local_trylock_t *tl; \
136+
local_trylock_t *__tl; \
137137
\
138138
preempt_disable(); \
139-
tl = (lock); \
140-
if (READ_ONCE(tl->acquired)) { \
139+
__tl = (lock); \
140+
if (READ_ONCE(__tl->acquired)) { \
141141
preempt_enable(); \
142-
tl = NULL; \
142+
__tl = NULL; \
143143
} else { \
144-
WRITE_ONCE(tl->acquired, 1); \
144+
WRITE_ONCE(__tl->acquired, 1); \
145145
local_trylock_acquire( \
146-
(local_lock_t *)tl); \
146+
(local_lock_t *)__tl); \
147147
} \
148-
!!tl; \
148+
!!__tl; \
149149
})
150150

151151
#define __local_trylock_irqsave(lock, flags) \
152152
({ \
153-
local_trylock_t *tl; \
153+
local_trylock_t *__tl; \
154154
\
155155
local_irq_save(flags); \
156-
tl = (lock); \
157-
if (READ_ONCE(tl->acquired)) { \
156+
__tl = (lock); \
157+
if (READ_ONCE(__tl->acquired)) { \
158158
local_irq_restore(flags); \
159-
tl = NULL; \
159+
__tl = NULL; \
160160
} else { \
161-
WRITE_ONCE(tl->acquired, 1); \
161+
WRITE_ONCE(__tl->acquired, 1); \
162162
local_trylock_acquire( \
163-
(local_lock_t *)tl); \
163+
(local_lock_t *)__tl); \
164164
} \
165-
!!tl; \
165+
!!__tl; \
166166
})
167167

168168
/* preemption or migration must be disabled before calling __local_lock_is_locked */
169169
#define __local_lock_is_locked(lock) READ_ONCE(this_cpu_ptr(lock)->acquired)
170170

171171
#define __local_lock_release(lock) \
172172
do { \
173-
local_trylock_t *tl; \
174-
local_lock_t *l; \
173+
local_trylock_t *__tl; \
174+
local_lock_t *__l; \
175175
\
176-
l = (local_lock_t *)(lock); \
177-
tl = (local_trylock_t *)l; \
178-
local_lock_release(l); \
176+
__l = (local_lock_t *)(lock); \
177+
__tl = (local_trylock_t *)__l; \
178+
local_lock_release(__l); \
179179
_Generic((lock), \
180180
local_trylock_t *: ({ \
181-
lockdep_assert(tl->acquired == 1); \
182-
WRITE_ONCE(tl->acquired, 0); \
181+
lockdep_assert(__tl->acquired == 1); \
182+
WRITE_ONCE(__tl->acquired, 0); \
183183
}), \
184184
local_lock_t *: (void)0); \
185185
} while (0)
@@ -223,12 +223,12 @@ typedef spinlock_t local_trylock_t;
223223
#define INIT_LOCAL_LOCK(lockname) __LOCAL_SPIN_LOCK_UNLOCKED((lockname))
224224
#define INIT_LOCAL_TRYLOCK(lockname) __LOCAL_SPIN_LOCK_UNLOCKED((lockname))
225225

226-
#define __local_lock_init(l) \
226+
#define __local_lock_init(__l) \
227227
do { \
228-
local_spin_lock_init((l)); \
228+
local_spin_lock_init((__l)); \
229229
} while (0)
230230

231-
#define __local_trylock_init(l) __local_lock_init(l)
231+
#define __local_trylock_init(__l) __local_lock_init(__l)
232232

233233
#define __local_lock(__lock) \
234234
do { \

0 commit comments

Comments
 (0)