public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Arnd Bergmann <arnd@kernel.org>
Cc: Bill Metzenthen <billm@melbpc.org.au>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	x86@kernel.org, Arnd Bergmann <arnd@arndb.de>,
	"H. Peter Anvin" <hpa@zytor.com>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86: math-emu: Fix function cast warning
Date: Mon, 22 Mar 2021 21:35:26 +0100	[thread overview]
Message-ID: <20210322203526.GB1955909@gmail.com> (raw)
In-Reply-To: <20210322170610.1823153-1-arnd@kernel.org>


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

> From: Arnd Bergmann <arnd@arndb.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@arndb.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

      reply	other threads:[~2021-03-22 20:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-22 17:06 [PATCH] x86: math-emu: Fix function cast warning Arnd Bergmann
2021-03-22 20:35 ` Ingo Molnar [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210322203526.GB1955909@gmail.com \
    --to=mingo@kernel.org \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=billm@melbpc.org.au \
    --cc=bp@alien8.de \
    --cc=gustavoars@kernel.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox