Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2006931ybv; Fri, 14 Feb 2020 09:41:13 -0800 (PST) X-Google-Smtp-Source: APXvYqzjzKiBjEv6Io27xV2eenMmuZNM9sHY6xCR5aQg+XTT5u1y8QoHtfKGL9E1z3lBw/7fLJbd X-Received: by 2002:a9d:7f8d:: with SMTP id t13mr3017384otp.175.1581702073489; Fri, 14 Feb 2020 09:41:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581702073; cv=none; d=google.com; s=arc-20160816; b=PMlKRE1nRLw0owXeoP95akNX+ea2L70h4AzY7d8GXYqDp4/Mb5/QazohfHOFgBDZ22 WlaLuN/620/OwCDi7o1BsY12Bto2onoKGthU6Qgato5ht9gE6Sq9Xl8yMrFlSkWVam3v IK0BY8bmMNkzcGr/AKiZ3LuvroNg9ZOBGzbVW+CHWHevYSU25rtSlstABA9l6nLI082b 0tpEqsPOH/kJqnD1dARrM6UfH73cPSXsV06YgZKqyhwvKe3hNEdMP1lWls+OiCpst0gF DMCdeY5KAbdTmrLGozY4TohLZs6mSmHXHesbCVc+iSiyxwNi9fCt0q4KlrR9AzO05Z/u iBkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=C1CClW4tYZ79EFJV8GTAjHe6cQOLCCNvZ/tb7p+kbKo=; b=PPdpBNQMskARbIAdIxcX88YY8tuM0cHf4hbTdBJRPPP2ufQtvtN6pGjA1ldPPwaghm lRJwESLpgIS0a3KwHddWS0RfFkEeTOpe67qWn8z1vUmRUlJPGrM+lpOQyx812brI2RvN NOl2Cn/ye4IjJAr9QPtorKqEgIcVVjhZfgw0JBT1tVIPVj6tYQyItlWaU3Obns76f2T2 N0adIHxALx+mFltVKeYvDEVwVXtwwSQH9KLqjKyn7fdUrQA1qZ8ysNa3GWiMDzW1gtcd xQIydPHZPgD/AceGIz+Zn3i/Ptbx3TeVlSUxk5CyudNRHVJE5xPAPNN9MCNm3wYxXXMf khSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=jwXJ9r3d; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s129si2841819oig.177.2020.02.14.09.41.01; Fri, 14 Feb 2020 09:41:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=jwXJ9r3d; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389809AbgBNRky (ORCPT + 99 others); Fri, 14 Feb 2020 12:40:54 -0500 Received: from mail-io1-f66.google.com ([209.85.166.66]:41148 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389839AbgBNRkx (ORCPT ); Fri, 14 Feb 2020 12:40:53 -0500 Received: by mail-io1-f66.google.com with SMTP id m25so11400413ioo.8 for ; Fri, 14 Feb 2020 09:40:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=C1CClW4tYZ79EFJV8GTAjHe6cQOLCCNvZ/tb7p+kbKo=; b=jwXJ9r3dQp/+12/mbTFMCINEUOtuUUs4zVoRGjZh0Jq9CkblELQN4A56KA8aiGl1rN nkE2kqBst9wANEpXI7757f5nrnoVW7516f/SpwI3dLJ97L/AeQAZnOzEQXZKSXd+5gwT zXrtjMkFKNqanCANOJcqvHaBMZZ/f2kdcSA+0Yyyz2/9lqpeOuT5Py6uxuFb4UCyEojZ zH0eaKYFXQtq2uQLLrJXsDRxB2rs84YUiUsmPhvNxMRxhclsTmehsmNqbuAh7eBjzguq aX47um+kgMO9UePZ8xabTT5VazkH6rv1QT2FYdEMjAqq4KBnJc6LCerOXaqJFddBQD1A AZEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=C1CClW4tYZ79EFJV8GTAjHe6cQOLCCNvZ/tb7p+kbKo=; b=qPvUmFSMjyHJYnHCzDt67FDLfuyXylDWt87DvIpYatV3BjwAdErTYS5zEvPUxW3JLM 2i0u591XxIo/DQw4e1KErG5poCVCS+gE33R+0o/7WdVUr2sbu5k8JVOUuu7FCILzGSlx XJ3ZC3jbfDnC+TKxSV14BvXtJ+QExVXj6E/lt6AH/0CQa3n5VWmd7QemJPaBwelzQO1u bhdKZ8ltkP1rDLEfjcp8kPUPVkUEzgkN+Ty2mMJa5rHvkfxZ8G4vCtrulY5EuOzlbZZ8 WT0jREqYQin1H7sDjGFua8gaJzN23IOutzWBNmROt2z15updJzrG2VvDYFBOUqKpaMtG bk1g== X-Gm-Message-State: APjAAAWX8zAevCtvi9O2L2qPHyg3fJ2Lstw9NB1/nDFqVZ643YJHBJ8O xh9yMo3OwQs+U1E9Dp9AzqNq7BAyY8E/ciYhezkJOA== X-Received: by 2002:a02:3312:: with SMTP id c18mr3493979jae.24.1581702052559; Fri, 14 Feb 2020 09:40:52 -0800 (PST) MIME-Version: 1.0 References: <1581695768-6123-1-git-send-email-cai@lca.pw> <20200214165923.GA20690@linux.intel.com> <1581700124.7365.70.camel@lca.pw> In-Reply-To: <1581700124.7365.70.camel@lca.pw> From: Jim Mattson Date: Fri, 14 Feb 2020 09:40:41 -0800 Message-ID: Subject: Re: [PATCH] kvm/emulate: fix a -Werror=cast-function-type To: Qian Cai Cc: Sean Christopherson , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Joerg Roedel , kvm list , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 14, 2020 at 9:08 AM Qian Cai 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 > > > --- > > > 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.