linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Christopher Li <sparse@chrisli.org>
Cc: Josh Triplett <josh@kernel.org>,
	Linux-Sparse <linux-sparse@vger.kernel.org>
Subject: Re: [PATCH] lib: __builtin_object_size should accept void *
Date: Thu, 24 Nov 2016 05:28:34 +0200	[thread overview]
Message-ID: <20161124052744-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <CANeU7Qm4Q7fawnTkGgsgQoiLJXwJLJng+4Y60+n5c_nbK-vRgQ@mail.gmail.com>

On Thu, Nov 24, 2016 at 08:16:24AM +0800, Christopher Li wrote:
> A similar patch has been applied:
> 
> Chris
> 
> commit f2bf519e1da89779380fd781c0eb28aae415979d
> Author: Lance Richardson <lrichard@redhat.com>
> Date:   Wed Sep 21 10:13:58 2016 -0400
> 
>     sparse: update __builtin_object_size() prototype
> 
>     Sparse emits a large number of warnings for the linux kernel source
>     tree of the form:
>         ./arch/x86/include/asm/uaccess.h:735:18: \
>             warning: incorrect type in argument 1 (different modifiers)
>         ./arch/x86/include/asm/uaccess.h:735:18:    expected void *<noident>
>         ./arch/x86/include/asm/uaccess.h:735:18:    got void const *from
> 
>     Fix by making the first parameter to __builtin_object_size()
>     type "const void *" instead of "void *", which is consistent with GCC
>     behavior (the prototype for this builtin in GCC documentation is evidently
>     incorrect).
> 
>     Signed-off-by: Lance Richardson <lrichard@redhat.com>
>     Acked-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
>     Signed-off-by: Christopher Li <sparse@chrisli.org>

Doesn't seem to be pushed yet - at least I don't see it in master
on git://git.kernel.org/pub/scm/devel/sparse/sparse.git


> diff --git a/lib.c b/lib.c
> index d5b56b0..2d66aa0 100644
> --- a/lib.c
> +++ b/lib.c
> @@ -888,7 +888,7 @@ void declare_builtin_functions(void)
>         add_pre_buffer("extern long double __builtin_nanl(const char *);\n");
> 
>         /* And some __FORTIFY_SOURCE ones.. */
> -       add_pre_buffer ("extern __SIZE_TYPE__
> __builtin_object_size(void *, int);\n");
> +       add_pre_buffer ("extern __SIZE_TYPE__
> __builtin_object_size(const void *, int);\n");
>         add_pre_buffer ("extern void * __builtin___memcpy_chk(void *,
> const void *, __SIZE_TYPE__, __SIZE_TYPE__);\n");
>         add_pre_buffer ("extern void * __builtin___memmove_chk(void *,
> const void *, __SIZE_TYPE__, __SIZE_TYPE__);\n");
>         add_pre_buffer ("extern void * __builtin___mempcpy_chk(void *,
> const void *, __SIZE_TYPE__, __SIZE_TYPE__);\n");
> 
> 
> 
> On Thu, Nov 24, 2016 at 4:24 AM, Michael S. Tsirkin <mst@redhat.com> wrote:
> > I'm seeing these warnings with current Linux:
> > ./arch/x86/include/asm/uaccess.h:705:18: warning: incorrect type in argument 1 (different modifiers)
> > ./arch/x86/include/asm/uaccess.h:705:18:    expected void *<noident>
> > ./arch/x86/include/asm/uaccess.h:705:18:    got void const *from
> >
> > Because of this code:
> >
> > static __always_inline unsigned long __must_check
> > copy_to_user(void __user *to, const void *from, unsigned long n)
> > {
> >         int sz = __compiletime_object_size(from);
> >
> > ...
> > }
> >
> > where we have
> >
> > # define __compiletime_object_size(obj) __builtin_object_size(obj, 0)
> >
> > to fix, mark the argument as const void *.
> >
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> >
> > Sorry if this has already been reported/fixed.
> >
> >  lib.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/lib.c b/lib.c
> > index d5b56b0..2d66aa0 100644
> > --- a/lib.c
> > +++ b/lib.c
> > @@ -888,7 +888,7 @@ void declare_builtin_functions(void)
> >         add_pre_buffer("extern long double __builtin_nanl(const char *);\n");
> >
> >         /* And some __FORTIFY_SOURCE ones.. */
> > -       add_pre_buffer ("extern __SIZE_TYPE__ __builtin_object_size(void *, int);\n");
> > +       add_pre_buffer ("extern __SIZE_TYPE__ __builtin_object_size(const void *, int);\n");
> >         add_pre_buffer ("extern void * __builtin___memcpy_chk(void *, const void *, __SIZE_TYPE__, __SIZE_TYPE__);\n");
> >         add_pre_buffer ("extern void * __builtin___memmove_chk(void *, const void *, __SIZE_TYPE__, __SIZE_TYPE__);\n");
> >         add_pre_buffer ("extern void * __builtin___mempcpy_chk(void *, const void *, __SIZE_TYPE__, __SIZE_TYPE__);\n");
> > --
> > MST
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2016-11-24  3:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-23 20:24 [PATCH] lib: __builtin_object_size should accept void * Michael S. Tsirkin
2016-11-24  0:16 ` Christopher Li
2016-11-24  3:28   ` Michael S. Tsirkin [this message]
2016-11-24  4:01     ` Christopher Li
2016-11-24  4:35       ` Josh Triplett
2016-11-24  5:03         ` Christopher Li
2016-11-24  5:19           ` Josh Triplett
2016-11-24  5:49             ` Christopher Li

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=20161124052744-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=josh@kernel.org \
    --cc=linux-sparse@vger.kernel.org \
    --cc=sparse@chrisli.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).