lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20210322203526.GB1955909@gmail.com>
Date:   Mon, 22 Mar 2021 21:35:26 +0100
From:   Ingo Molnar <mingo@...nel.org>
To:     Arnd Bergmann <arnd@...nel.org>
Cc:     Bill Metzenthen <billm@...bpc.org.au>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        x86@...nel.org, Arnd Bergmann <arnd@...db.de>,
        "H. Peter Anvin" <hpa@...or.com>,
        "Gustavo A. R. Silva" <gustavoars@...nel.org>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] x86: math-emu: Fix function cast warning


* Arnd Bergmann <arnd@...nel.org> wrote:

> From: Arnd Bergmann <arnd@...db.de>
> 
> Building with 'make W=1', gcc points out that casting between
> incompatible function types can be dangerous:
> 
> arch/x86/math-emu/fpu_trig.c:1638:60: error: cast between incompatible function types from ‘int (*)(FPU_REG *, u_char)’ {aka ‘int (*)(struct fpu__reg *, unsigned char)’} to ‘void (*)(FPU_REG *, u_char)’ {aka ‘void (*)(struct fpu__reg *, unsigned char)’} [-Werror=cast-function-type]
>  1638 |         fprem, fyl2xp1, fsqrt_, fsincos, frndint_, fscale, (FUNC_ST0) fsin, fcos
>       |                                                            ^
> 
> This one seems harmless, but it is easy enough to work around it by
> adding an intermediate function that adjusts the return type.
> 
> Signed-off-by: Arnd Bergmann <arnd@...db.de>
> ---
>  arch/x86/math-emu/fpu_trig.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/math-emu/fpu_trig.c b/arch/x86/math-emu/fpu_trig.c
> index 4a9887851ad8..aebfdb244cb4 100644
> --- a/arch/x86/math-emu/fpu_trig.c
> +++ b/arch/x86/math-emu/fpu_trig.c
> @@ -547,7 +547,7 @@ static void frndint_(FPU_REG *st0_ptr, u_char st0_tag)
>  		single_arg_error(st0_ptr, st0_tag);
>  }
>  
> -static int fsin(FPU_REG *st0_ptr, u_char tag)
> +static int do_fsin(FPU_REG *st0_ptr, u_char tag)
>  {
>  	u_char arg_sign = getsign(st0_ptr);
>  
> @@ -608,6 +608,11 @@ static int fsin(FPU_REG *st0_ptr, u_char tag)
>  	}
>  }
>  
> +static void fsin(FPU_REG *st0_ptr, u_char tag)
> +{
> +	fsin(st0_ptr, tag);
> +}
> +
>  static int f_cos(FPU_REG *st0_ptr, u_char tag)
>  {
>  	u_char st0_sign;

The existing nomenclature in that code is:

  static int f_cos(FPU_REG *st0_ptr, u_char tag)
  static void fcos(FPU_REG *st0_ptr, u_char st0_tag)

So I'd suggest naming the variant with a return value f_sin().

Thanks,

	Ingo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ