From: Qian Cai <cai@lca.pw>
To: Jim Mattson <jmattson@google.com>
Cc: Sean Christopherson <sean.j.christopherson@intel.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
Joerg Roedel <joro@8bytes.org>, kvm list <kvm@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] kvm/emulate: fix a -Werror=cast-function-type
Date: Fri, 14 Feb 2020 14:14:06 -0500 [thread overview]
Message-ID: <1581707646.7365.72.camel@lca.pw> (raw)
In-Reply-To: <CALMp9eTRn-46oKg5a9h79EZOvHGwT=8ZZN15Zmy5NUYsd+r8wQ@mail.gmail.com>
On Fri, 2020-02-14 at 09:40 -0800, Jim Mattson wrote:
> On Fri, Feb 14, 2020 at 9:08 AM Qian Cai <cai@lca.pw> wrote:
> >
> > On Fri, 2020-02-14 at 08:59 -0800, Sean Christopherson wrote:
> > > 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.
> >
> > I am doing W=1 on linux-next where some of the warnings might be silly but the
> > recent commit changes all warnings to errors forces me having to silence those
> > somehow.
> >
> > >
> > > If not, will either of these work?
> > >
> > > rc = fastop(ctxt, (void *)ctxt->execute);
> > >
> > > or
> > > rc = fastop(ctxt, (fastop_t)(void *)ctxt->execute);
> >
> > I have no strong preference. I originally thought just to go back the previous
> > code style where might be more acceptable, but it is up to maintainers.
>
> It seems misguided to define a local variable just to get an implicit
> cast from (void *) to (fastop_t). Sean's first suggestion gives you
> the same implicit cast without the local variable. The second
> suggestion makes both casts explicit.
OK, I'll do a v2 using the first suggestion which looks simpler once it passed
compilations.
next prev parent reply other threads:[~2020-02-14 19:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-14 15:56 [PATCH] kvm/emulate: fix a -Werror=cast-function-type Qian Cai
2020-02-14 16:59 ` Sean Christopherson
2020-02-14 17:08 ` Qian Cai
2020-02-14 17:40 ` Jim Mattson
2020-02-14 19:14 ` Qian Cai [this message]
2020-02-14 19:33 ` Paolo Bonzini
2020-02-14 19:54 ` Sean Christopherson
2020-02-17 14:47 ` Qian Cai
2020-02-17 16:32 ` Paolo Bonzini
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=1581707646.7365.72.camel@lca.pw \
--to=cai@lca.pw \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=sean.j.christopherson@intel.com \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.com \
/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;
as well as URLs for NNTP newsgroup(s).