Re: [PATCH 1/2] x86/bootflag: Change some static functions to bool
From: Uros Bizjak
Date: Mon Feb 24 2025 - 02:24:37 EST
On Mon, Feb 24, 2025 at 8:18 AM Jiri Slaby <jirislaby@xxxxxxxxxx> wrote:
>
> On 29. 01. 25, 16:47, Uros Bizjak wrote:
> > The return values of some functions are of boolean type. Change the
> > type of these function to bool and adjust their return values.
> >
> > No functional change intended.
> >
> > Signed-off-by: Uros Bizjak <ubizjak@xxxxxxxxx>
> > Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> > Cc: Ingo Molnar <mingo@xxxxxxxxxx>
> > Cc: Borislav Petkov <bp@xxxxxxxxx>
> > Cc: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
> > Cc: "H. Peter Anvin" <hpa@xxxxxxxxx>
> > ---
> > arch/x86/kernel/bootflag.c | 12 ++++++------
> > 1 file changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/arch/x86/kernel/bootflag.c b/arch/x86/kernel/bootflag.c
> > index 3fed7ae58b60..4d89a2d80d0f 100644
> > --- a/arch/x86/kernel/bootflag.c
> > +++ b/arch/x86/kernel/bootflag.c
> > @@ -20,7 +20,7 @@
> >
> > int sbf_port __initdata = -1; /* set via acpi_boot_init() */
> >
> > -static int __init parity(u8 v)
> > +static bool __init parity(u8 v)
> > {
> > int x = 0;
> > int i;
> > @@ -30,7 +30,7 @@ static int __init parity(u8 v)
> > v >>= 1;
> > }
> >
> > - return x;
> > + return !!x;
>
> This "!!" is unnecessary and only obfuscates the code, right?
Not really, this idiom is used in place of (x != 0) to change the type
to the return type of the function in a pedantic way.
Uros.