Linux SPARSE checker discussions
 help / color / mirror / Atom feed
* [PATCH] Sparse: fix the setting of __SIZE_TYPE__ in lib.c
@ 2005-12-17 20:40 Mika Kukkonen
  2005-12-17 20:56 ` Linus Torvalds
  0 siblings, 1 reply; 2+ messages in thread
From: Mika Kukkonen @ 2005-12-17 20:40 UTC (permalink / raw)
  To: torvalds; +Cc: linux-sparse

[-- Attachment #1: Type: text/plain, Size: 545 bytes --]

I was doing some janitorial work on kernel lib/string.c (patch to
kernel mailing list coming later), and in particular removed the
"#undef memcmp" line. This caused sparse to barf:

mika@desktop:~/work/repos/git/linux-2.6$ make C=1 lib
  CHK     include/linux/version.h
  CHECK   lib/string.c
lib/string.c:519:5: error: symbol '__builtin_memcmp' redeclared with
different type (originally declared at builtin:37) - incompatible
argument 3 (different type sizes)
  CC      lib/string.o

Does the attached patch make sense?

--MiKu

[-- Attachment #2: fix-size_type-setting.patch --]
[-- Type: application/octet-stream, Size: 984 bytes --]

---

 lib.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/lib.c b/lib.c
index d765d75..d80bc28 100644
--- a/lib.c
+++ b/lib.c
@@ -479,10 +479,13 @@ void create_builtin_stream(void)
 
 	// gcc defines __SIZE_TYPE__ to be size_t.  For linux/i86 and
 	// solaris/sparc that is really "unsigned int" and for linux/x86_64
-	// it is "long unsigned int".  In either case we can probably
-	// get away with this.  We need the #ifndef as cgcc will define
+	// it is "long unsigned int". We need the #ifndef as cgcc will define
 	// the right __SIZE_TYPE__.
-	add_pre_buffer("#weak_define __SIZE_TYPE__ long unsigned int\n");
+	if (sizeof(size_t) == sizeof(unsigned int))
+		add_pre_buffer("#weak_define __SIZE_TYPE__ unsigned int\n");
+	else
+		add_pre_buffer("#weak_define __SIZE_TYPE__ long unsigned int\n");
+
 	add_pre_buffer("#weak_define __STDC__ 1\n");
 
 	add_pre_buffer("#define __builtin_stdarg_start(a,b) ((a) = (__builtin_va_list)(&(b)))\n");



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

end of thread, other threads:[~2005-12-17 20:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-17 20:40 [PATCH] Sparse: fix the setting of __SIZE_TYPE__ in lib.c Mika Kukkonen
2005-12-17 20:56 ` Linus Torvalds

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