linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] lib: __builtin_object_size should accept void *
@ 2016-11-23 20:24 Michael S. Tsirkin
  2016-11-24  0:16 ` Christopher Li
  0 siblings, 1 reply; 8+ messages in thread
From: Michael S. Tsirkin @ 2016-11-23 20:24 UTC (permalink / raw)
  To: Josh Triplett; +Cc: linux-sparse

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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-11-24  5:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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).