Re: [PATCH] x86: squash lines for simple wrapper functions

From: Ingo Molnar
Date: Thu Sep 08 2016 - 02:34:09 EST



* Masahiro Yamada <yamada.masahiro@xxxxxxxxxxxxx> wrote:

> Remove unneeded variables and assignments. I am also removing
> unnecessary parentheses while I am here.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@xxxxxxxxxxxxx>
> ---
>
> arch/x86/kernel/apic/apic_flat_64.c | 16 +++-------------
> arch/x86/kernel/apic/apic_numachip.c | 5 +----
> arch/x86/kernel/apic/x2apic_uv_x.c | 5 +----
> arch/x86/mm/pat_rbtree.c | 4 +---
> arch/x86/platform/uv/bios_uv.c | 7 ++-----
> arch/x86/platform/uv/tlb_uv.c | 6 +-----
> 6 files changed, 9 insertions(+), 34 deletions(-)
>
> diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
> index 5b2ae10..c7228f9 100644
> --- a/arch/x86/kernel/apic/apic_flat_64.c
> +++ b/arch/x86/kernel/apic/apic_flat_64.c
> @@ -116,27 +116,17 @@ static void flat_send_IPI_all(int vector)
>
> static unsigned int flat_get_apic_id(unsigned long x)
> {
> - unsigned int id;
> -
> - id = (((x)>>24) & 0xFFu);
> -
> - return id;
> + return ((x) >> 24) & 0xFFu;

So while we are removing unnecessary things, exactly why does the 'x' need
parentheses?

> static unsigned long set_apic_id(unsigned int id)
> {
> - unsigned long x;
> -
> - x = ((id & 0xFFu)<<24);
> - return x;
> + return (id & 0xFFu) << 24;

'id' is already unsigned, why does the 'u' have to be stressed in the literal?
(Ditto for other places as well)

> static unsigned long numachip1_set_apic_id(unsigned int id)
> {
> - unsigned long x;
> -
> - x = ((id & 0xffU) << 24);
> - return x;
> + return (id & 0xffU) << 24;
> }

Why is the spelling of the literal inconsistent here with the other patterns?

> +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
> @@ -533,11 +533,8 @@ static unsigned int x2apic_get_apic_id(unsigned long x)
>
> static unsigned long set_apic_id(unsigned int id)
> {
> - unsigned long x;
> -
> /* maskout x2apic_extra_bits ? */
> - x = id;
> - return x;
> + return id;
> }

This was clearly left there to document a quirk and as a placeholder for future
changes.

Thanks,

Ingo