This commit replaced two hard-to-distinguish variables ______r and ______f to improve code readability and reduce variable name shadowing issue. ______r is renamed by leveraging __UNIQUE_ID(branch_check) in ___branch_check__, and callers of the affected macros are adjusted. __UNIQUE_ID(branch_check) will generate unique variable names during compilation, which eliminates the need for ______r. This avoids the variable name shadowing issue, or at least makes those wishing to cause shadowing problems work much harder to do so. ______f in ftrace_likely_data struct is renamed using __UNIQUE_ID(branch_check_data), following the same rationale above. The same idea is used for the commit 589a9785ee3a ("min/max: remove sparse warnings when they're nested"), and commit 24ba53017e18 ("rcu: Replace ________p1 and _________p1 with __UNIQUE_ID(rcu)"). Signed-off-by: Chun-Hung Tseng <henrybear327@xxxxxxxxx> Signed-off-by: Jim Huang <jserv@xxxxxxxxxxxxxxxx> --- include/linux/compiler.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 8c252e073bd8..b95e0990d52f 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -19,20 +19,20 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, #define likely_notrace(x) __builtin_expect(!!(x), 1) #define unlikely_notrace(x) __builtin_expect(!!(x), 0) -#define __branch_check__(x, expect, is_constant) ({ \ - long ______r; \ +#define __branch_check__(x, local, local_data, expect, is_constant) ({ \ + long local; \ static struct ftrace_likely_data \ __aligned(4) \ __section("_ftrace_annotated_branch") \ - ______f = { \ + local_data = { \ .data.func = __func__, \ .data.file = __FILE__, \ .data.line = __LINE__, \ }; \ - ______r = __builtin_expect(!!(x), expect); \ - ftrace_likely_update(&______f, ______r, \ + local = __builtin_expect(!!(x), expect); \ + ftrace_likely_update(&local_data, local, \ expect, is_constant); \ - ______r; \ + local; \ }) /* @@ -41,10 +41,14 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, * written by Daniel Walker. */ # ifndef likely -# define likely(x) (__branch_check__(x, 1, __builtin_constant_p(x))) +# define likely(x) (__branch_check__(x, __UNIQUE_ID(branch_check), \ + __UNIQUE_ID(branch_check_data), 1, \ + __builtin_constant_p(x))) # endif # ifndef unlikely -# define unlikely(x) (__branch_check__(x, 0, __builtin_constant_p(x))) +# define unlikely(x) (__branch_check__(x, __UNIQUE_ID(branch_check), \ + __UNIQUE_ID(branch_check_data), 0, \ + __builtin_constant_p(x))) # endif #ifdef CONFIG_PROFILE_ALL_BRANCHES -- 2.34.1