Linux SPARSE checker discussions
 help / color / mirror / Atom feed
From: Mika Kukkonen <mikukkon@iki.fi>
To: torvalds@osdl.org
Cc: linux-sparse@vger.kernel.org
Subject: [PATCH] Sparse: fix the setting of __SIZE_TYPE__ in lib.c
Date: Sat, 17 Dec 2005 22:40:49 +0200	[thread overview]
Message-ID: <4301cff60512171240v3436593ei44e662a82893cc0a@mail.gmail.com> (raw)

[-- 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");



             reply	other threads:[~2005-12-17 20:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-17 20:40 Mika Kukkonen [this message]
2005-12-17 20:56 ` [PATCH] Sparse: fix the setting of __SIZE_TYPE__ in lib.c Linus Torvalds

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=4301cff60512171240v3436593ei44e662a82893cc0a@mail.gmail.com \
    --to=mikukkon@iki.fi \
    --cc=linux-sparse@vger.kernel.org \
    --cc=torvalds@osdl.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