1
0
Fork 0
mirror of https://github.com/yshui/picom.git synced 2024-11-11 13:51:02 -05:00

utils: try to avoid variable shadowing in some macros

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2024-02-16 12:41:27 +00:00
parent 45ffdf9849
commit 9175489f65
No known key found for this signature in database
GPG key ID: D3A4405BE6CC17F4

View file

@ -58,11 +58,11 @@ safe_isnan(double a) {
/// being always true or false. /// being always true or false.
#define ASSERT_IN_RANGE(var, lower, upper) \ #define ASSERT_IN_RANGE(var, lower, upper) \
do { \ do { \
auto __tmp attr_unused = (var); \ auto __assert_in_range_tmp attr_unused = (var); \
_Pragma("GCC diagnostic push"); \ _Pragma("GCC diagnostic push"); \
_Pragma("GCC diagnostic ignored \"-Wtype-limits\""); \ _Pragma("GCC diagnostic ignored \"-Wtype-limits\""); \
assert(__tmp >= lower); \ assert(__assert_in_range_tmp >= lower); \
assert(__tmp <= upper); \ assert(__assert_in_range_tmp <= upper); \
_Pragma("GCC diagnostic pop"); \ _Pragma("GCC diagnostic pop"); \
} while (0) } while (0)
@ -112,9 +112,10 @@ safe_isnan(double a) {
#define to_u32_checked(val) \ #define to_u32_checked(val) \
({ \ ({ \
auto __to_tmp = (val); \ auto __to_tmp = (val); \
int64_t max attr_unused = UINT32_MAX; /* silence clang tautological \ int64_t __to_u32_max attr_unused = UINT32_MAX; /* silence clang \
tautological \
comparison warning */ \ comparison warning */ \
ASSERT_IN_RANGE(__to_tmp, 0, max); \ ASSERT_IN_RANGE(__to_tmp, 0, __to_u32_max); \
(uint32_t) __to_tmp; \ (uint32_t) __to_tmp; \
}) })