From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Behan Webster <behanw@converseincode.com>
Cc: arnd@arndb.de, linux-arch@vger.kernel.org,
linux-kernel@vger.kernel.org, dwmw2@infradead.org,
pageexec@freemail.hu, Mark Charlebois <charlebm@gmail.com>
Subject: Re: [PATCH v2] LLVMLinux: Remove warning about returning an uninitialized variable
Date: Sat, 22 Mar 2014 09:42:38 -0700 [thread overview]
Message-ID: <1395506558.2143.18.camel@dabdike.int.hansenpartnership.com> (raw)
In-Reply-To: <532DBC50.9040505@converseincode.com>
On Sat, 2014-03-22 at 09:37 -0700, Behan Webster wrote:
> On 03/22/14 09:29, James Bottomley wrote:
> > On Sat, 2014-03-22 at 08:48 -0700, behanw@converseincode.com wrote:
> >> From: Behan Webster <behanw@converseincode.com>
> >>
> >> Fix uninitialized return code in default case in cmpxchg-local.h
> >>
> >> This patch fixes the code to prevent an uninitialized return value that is detected
> >> when compiling with clang. The bug produces numerous warnings when compiling the
> >> Linux kernel with clang.
> >>
> >> Signed-off-by: Behan Webster <behanw@converseincode.com>
> >> Signed-off-by: Mark Charlebois <charlebm@gmail.com>
> >> ---
> >> include/asm-generic/cmpxchg-local.h | 1 +
> >> 1 file changed, 1 insertion(+)
> >>
> >> diff --git a/include/asm-generic/cmpxchg-local.h b/include/asm-generic/cmpxchg-local.h
> >> index d8d4c89..9112111 100644
> >> --- a/include/asm-generic/cmpxchg-local.h
> >> +++ b/include/asm-generic/cmpxchg-local.h
> >> @@ -41,6 +41,7 @@ static inline unsigned long __cmpxchg_local_generic(volatile void *ptr,
> >> break;
> >> default:
> >> wrong_size_cmpxchg(ptr);
> >> + __builtin_unreachable();
> > No, that's got to be unreachable() so that it works in all compilers,
> > (__builtin_unreachable is a gcc-4 ism).
> It is also supported by clang.
OK, but it's not supported by gcc-3. So gcc-3 would crap out seeing the
statement, which is why we have to wrapper it.
> > Got to say this still looks wrong. If wrong_size_cmpxchg() cannot
> > return, the function should be annotated as such with __noreturn (like
> > panic()) so the unreachable() should be superfluous.
> Okay. I can try that instead.
Great; This seems to work for me (but then my compiler doesn't see the
unreachable problem).
James
---
diff --git a/include/asm-generic/cmpxchg-local.h b/include/asm-generic/cmpxchg-local.h
index d8d4c89..70bef78 100644
--- a/include/asm-generic/cmpxchg-local.h
+++ b/include/asm-generic/cmpxchg-local.h
@@ -4,7 +4,8 @@
#include <linux/types.h>
#include <linux/irqflags.h>
-extern unsigned long wrong_size_cmpxchg(volatile void *ptr);
+extern unsigned long wrong_size_cmpxchg(volatile void *ptr)
+ __noreturn;
/*
* Generic version of __cmpxchg_local (disables interrupts). Takes an unsigned
next prev parent reply other threads:[~2014-03-22 16:42 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-22 6:38 [PATCH] " behanw
2014-03-22 10:01 ` Arnd Bergmann
2014-03-22 15:45 ` Behan Webster
2014-03-22 15:48 ` [PATCH v2] " behanw
2014-03-22 16:21 ` Sam Ravnborg
2014-03-22 16:31 ` Behan Webster
2014-03-22 16:35 ` [PATCH v3] " behanw
2014-03-22 16:29 ` [PATCH v2] " James Bottomley
2014-03-22 16:37 ` Behan Webster
2014-03-22 16:42 ` James Bottomley [this message]
2014-03-23 6:32 ` Behan Webster
2014-03-24 5:53 ` [PATCH v4] " behanw
2014-03-25 17:16 ` Arnd Bergmann
2014-03-24 9:46 ` David Howells
2014-03-31 20:52 ` [PATCH] " H. Peter Anvin
2014-03-31 22:10 ` Behan Webster
2014-03-31 22:11 ` H. Peter Anvin
2014-03-31 22:16 ` Behan Webster
2014-03-31 22:19 ` H. Peter Anvin
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=1395506558.2143.18.camel@dabdike.int.hansenpartnership.com \
--to=james.bottomley@hansenpartnership.com \
--cc=arnd@arndb.de \
--cc=behanw@converseincode.com \
--cc=charlebm@gmail.com \
--cc=dwmw2@infradead.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pageexec@freemail.hu \
/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
all inboxes | Powered by JetHome®