public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86: suppress sparse warning in copy_to_user()
@ 2016-10-04  7:33 Johannes Berg
  2016-10-04  7:51 ` Jan Beulich
  0 siblings, 1 reply; 6+ messages in thread
From: Johannes Berg @ 2016-10-04  7:33 UTC (permalink / raw)
  To: x86
  Cc: Jan Beulich, Ingo Molnar, Thomas Gleixner, H. Peter Anvin,
	linux-kernel, Johannes Berg

From: Johannes Berg <johannes.berg@intel.com>

__compiletime_object_size() is simply defined to __builtin_object_size()
which gcc declares with (void *, int type) prototype. This is also done
by sparse, since it follows gcc, which leads it to warn, many times, on
any usage of copy_to_user(), about it:

  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

Suppress this by adding a (void *) cast. The compiler probably should
have declared it as const, but as it doesn't this is necessary. If it
changes, then the cast also won't matter.

Fixes: 7a3d9b0f3abbe ("x86: Unify copy_to_user() and add size checking to it")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 arch/x86/include/asm/uaccess.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
index 2131c4ce7d8a..0bd4a5a86199 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -732,7 +732,7 @@ copy_from_user(void *to, const void __user *from, unsigned long n)
 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);
+	int sz = __compiletime_object_size((void *)from);
 
 	kasan_check_read(from, n);
 
-- 
2.8.1

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

end of thread, other threads:[~2016-10-04  9:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-04  7:33 [PATCH] x86: suppress sparse warning in copy_to_user() Johannes Berg
2016-10-04  7:51 ` Jan Beulich
2016-10-04  8:02   ` Johannes Berg
2016-10-04  8:35     ` Jan Beulich
2016-10-04  8:49       ` Johannes Berg
2016-10-04  9:03         ` Jan Beulich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox