From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 06/11] KVM: vgic: declare probe function pointer as const
Date: Mon, 8 Sep 2014 12:03:14 +0100 [thread overview]
Message-ID: <20140908110314.GG26030@arm.com> (raw)
In-Reply-To: <CAKv+Gu8vAuHfnq5BfV=wac8SP3VYMizxg_7K4Baitj0TbWfYaw@mail.gmail.com>
On Sun, Sep 07, 2014 at 11:34:57AM +0100, Ard Biesheuvel wrote:
> > We extract the vgic probe function from the of_device_id data pointer,
> > which is const. Kill the sparse warning by ensuring that the local
> > function pointer is also marked as const.
> >
> > Cc: Marc Zyngier <marc.zyngier@arm.com>
> > Signed-off-by: Will Deacon <will.deacon@arm.com>
> > ---
> > virt/kvm/arm/vgic.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
> > index d1cfe672b9d7..efe6eee2e7eb 100644
> > --- a/virt/kvm/arm/vgic.c
> > +++ b/virt/kvm/arm/vgic.c
> > @@ -1557,8 +1557,8 @@ static const struct of_device_id vgic_ids[] = {
> > int kvm_vgic_hyp_init(void)
> > {
> > const struct of_device_id *matched_id;
> > - int (*vgic_probe)(struct device_node *,const struct vgic_ops **,
> > - const struct vgic_params **);
> > + const int (*vgic_probe)(struct device_node *,const struct vgic_ops **,
> > + const struct vgic_params **);
> > struct device_node *vgic_node;
> > int ret;
> >
>
> Hi all,
Hi Ard,
> I noticed this patch in kvmarm/next, and I think it is wrong.
>
> Sparse complains about the fact that you are assigning the value of a
> pointer to const data to a pointer to non-const data, and this is not
> what is happening. Dereferencing a function pointer does not give you
> an lvalue, so a function pointer points to const data by definition,
> and the assignment is fine and sparse is wrong. The fact that you can
> squelch the warning by typing the function pointer as returning a
> by-value const result only emphasizes how confused sparse gets about
> this.
Great, if you're fixing sparse (looks like you are) then we can drop this
patch from -next.
Cheers,
Will
next prev parent reply other threads:[~2014-09-08 11:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <540C32A8.1000409@linaro.org>
2014-09-07 10:34 ` [PATCH 06/11] KVM: vgic: declare probe function pointer as const Ard Biesheuvel
2014-09-08 11:03 ` Will Deacon [this message]
2014-08-26 14:13 [PATCH 00/11] Fix arm64 issues highlighted by sparse and smatch Will Deacon
2014-08-26 14:13 ` [PATCH 06/11] KVM: vgic: declare probe function pointer as const Will Deacon
2014-08-26 14:27 ` Marc Zyngier
2014-08-26 14:50 ` Christoffer Dall
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=20140908110314.GG26030@arm.com \
--to=will.deacon@arm.com \
--cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).