lkml.org 
[lkml]   [2020]   [Feb]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] kvm/emulate: fix a -Werror=cast-function-type
On Fri, Feb 14, 2020 at 10:56:08AM -0500, Qian Cai wrote:
> arch/x86/kvm/emulate.c: In function 'x86_emulate_insn':
> arch/x86/kvm/emulate.c:5686:22: error: cast between incompatible
> function types from 'int (*)(struct x86_emulate_ctxt *)' to 'void
> (*)(struct fastop *)' [-Werror=cast-function-type]
> rc = fastop(ctxt, (fastop_t)ctxt->execute);
>
> Fixes: 3009afc6e39e ("KVM: x86: Use a typedef for fastop functions")
> Signed-off-by: Qian Cai <cai@lca.pw>
> ---
> arch/x86/kvm/emulate.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> index ddbc61984227..17ae820cf59d 100644
> --- a/arch/x86/kvm/emulate.c
> +++ b/arch/x86/kvm/emulate.c
> @@ -5682,10 +5682,12 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt)
> ctxt->eflags &= ~X86_EFLAGS_RF;
>
> if (ctxt->execute) {
> - if (ctxt->d & Fastop)
> - rc = fastop(ctxt, (fastop_t)ctxt->execute);

Alternatively, can we do -Wno-cast-function-type? That's a silly warning
IMO.

If not, will either of these work?

rc = fastop(ctxt, (void *)ctxt->execute);

or
rc = fastop(ctxt, (fastop_t)(void *)ctxt->execute);

> - else
> + if (ctxt->d & Fastop) {
> + fastop_t fop = (void *)ctxt->execute;
> + rc = fastop(ctxt, fop);
> + } else {
> rc = ctxt->execute(ctxt);
> + }
> if (rc != X86EMUL_CONTINUE)
> goto done;
> goto writeback;
> --
> 1.8.3.1
>

\
 
 \ /
  Last update: 2020-02-14 18:00    [W:0.061 / U:5.776 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site