From: Ingo Molnar Date: Fri, 11 Apr 2025 05:40:55 +0000 (+0200) Subject: x86/alternatives: Simplify and clean up patch_cmp() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=3e6f47573ec3ed1d9dc50243fbcf50c87f740853;p=users%2Fdwmw2%2Flinux.git x86/alternatives: Simplify and clean up patch_cmp() - No need to cast over to 'struct smp_text_poke_loc *', void * is just fine for a binary search, - Use the canonical (a, b) input parameter nomenclature of cmp_func_t functions and rename the input parameters from (tp, elt) to (tpl_a, tpl_b). Signed-off-by: Ingo Molnar Cc: Juergen Gross Cc: "H . Peter Anvin" Cc: Linus Torvalds Cc: Peter Zijlstra Link: https://lore.kernel.org/r/20250411054105.2341982-44-mingo@kernel.org --- diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c index 14ca17dc36e82..f278655f09501 100644 --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -2498,13 +2498,11 @@ static __always_inline void *text_poke_addr(const struct smp_text_poke_loc *tp) return _stext + tp->rel_addr; } -static __always_inline int patch_cmp(const void *key, const void *elt) +static __always_inline int patch_cmp(const void *tpl_a, const void *tpl_b) { - struct smp_text_poke_loc *tp = (struct smp_text_poke_loc *) elt; - - if (key < text_poke_addr(tp)) + if (tpl_a < text_poke_addr(tpl_b)) return -1; - if (key > text_poke_addr(tp)) + if (tpl_a > text_poke_addr(tpl_b)) return 1; return 0; }