summaryrefslogtreecommitdiff
path: root/include/linux/bitops.h
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@redhat.com>2018-10-15 16:43:06 +0300
committerMiklos Szeredi <mszeredi@redhat.com>2018-10-15 16:43:06 +0300
commitedfa87281f4fa1b78a21f6db999935a2faa2f6b8 (patch)
treea8cf448df087ed559e97a09f1adf0bb5f7c59f12 /include/linux/bitops.h
parent18127429a854e7607b859484880b8e26cee9ddab (diff)
downloadlinux-edfa87281f4fa1b78a21f6db999935a2faa2f6b8.tar.xz
bitops: protect variables in bit_clear_unless() macro
Unprotected naming of local variables within bit_clear_unless() can easily lead to using the wrong scope. Noticed this by code review after having hit this issue in set_mask_bits() Signed-off-by: Miklos Szeredi <mszeredi@redhat.com> Fixes: 85ad1d13ee9b ("md: set MD_CHANGE_PENDING in a atomic region") Cc: Guoqing Jiang <gqjiang@suse.com>
Diffstat (limited to 'include/linux/bitops.h')
-rw-r--r--include/linux/bitops.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index d18ee0e63c32..705f7c442691 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -251,18 +251,18 @@ static __always_inline void __assign_bit(long nr, volatile unsigned long *addr,
#endif
#ifndef bit_clear_unless
-#define bit_clear_unless(ptr, _clear, _test) \
+#define bit_clear_unless(ptr, clear, test) \
({ \
- const typeof(*ptr) clear = (_clear), test = (_test); \
- typeof(*ptr) old, new; \
+ const typeof(*(ptr)) clear__ = (clear), test__ = (test);\
+ typeof(*(ptr)) old__, new__; \
\
do { \
- old = READ_ONCE(*ptr); \
- new = old & ~clear; \
- } while (!(old & test) && \
- cmpxchg(ptr, old, new) != old); \
+ old__ = READ_ONCE(*(ptr)); \
+ new__ = old__ & ~clear__; \
+ } while (!(old__ & test__) && \
+ cmpxchg(ptr, old__, new__) != old__); \
\
- !(old & test); \
+ !(old__ & test__); \
})
#endif