diff mbox

sparse: update __builtin_object_size() prototype

Message ID 1474467238-20939-1-git-send-email-lrichard@redhat.com (mailing list archive)
State Mainlined, archived
Headers show

Commit Message

Lance Richardson Sept. 21, 2016, 2:13 p.m. UTC
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>
---
 lib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Luc Van Oostenryck Nov. 7, 2016, 10:09 a.m. UTC | #1
On Wed, Sep 21, 2016 at 10:13:58AM -0400, Lance Richardson wrote:
> 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>
> ---
>  lib.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib.c b/lib.c
> index aa2af68..122dd6f 100644
> --- a/lib.c
> +++ b/lib.c
> @@ -917,7 +917,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");
> -- 

Acked-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>


Chris, can you please take this patch (or Johannes' one).
When compiling the kernel, there is more than 2000 false warnings
only for the uaccess.h case described here above.

Luc
--
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
Christopher Li Nov. 16, 2016, 10:52 p.m. UTC | #2
On Mon, Nov 7, 2016 at 6:09 PM, Luc Van Oostenryck
<luc.vanoostenryck@gmail.com> wrote:
>
> Acked-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
>
>
> Chris, can you please take this patch (or Johannes' one).
> When compiling the kernel, there is more than 2000 false warnings
> only for the uaccess.h case described here above.

Applied and pushed to "chrisl" repository.

Thanks

Chris
--
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
Luc Van Oostenryck Nov. 16, 2016, 11:28 p.m. UTC | #3
On Thu, Nov 17, 2016 at 06:52:51AM +0800, Christopher Li wrote:
> On Mon, Nov 7, 2016 at 6:09 PM, Luc Van Oostenryck
> <luc.vanoostenryck@gmail.com> wrote:
> >
> > Acked-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
> >
> >
> > Chris, can you please take this patch (or Johannes' one).
> > When compiling the kernel, there is more than 2000 false warnings
> > only for the uaccess.h case described here above.
> 
> Applied and pushed to "chrisl" repository.
> 
> Thanks
> 
> Chris
> --

Thanks.

BTW, how must we consider this "chrilsi" repository?
A bit like a -next repository or more like a working one?
Can we consider it as stable for git fetches & pulls?


Luc
--
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
Christopher Li Nov. 17, 2016, 8:28 a.m. UTC | #4
On Thu, Nov 17, 2016 at 7:28 AM, Luc Van Oostenryck
<luc.vanoostenryck@gmail.com> wrote:
>
> BTW, how must we consider this "chrilsi" repository?
> A bit like a -next repository or more like a working one?

It is a repository I use to stage change. I need to know
more about the difference between "-next" repository vs
a working one.

> Can we consider it as stable for git fetches & pulls?

So far it has been stable for git fetch and pulls.

The "review-xxxx" branches are not.

Chris
--
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
diff mbox

Patch

diff --git a/lib.c b/lib.c
index aa2af68..122dd6f 100644
--- a/lib.c
+++ b/lib.c
@@ -917,7 +917,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");