Re: [PATCH] mm/memory.c: remove warning from an uninitialized spinlock. was: Re: 2.6.21-rc7-mm2

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <bbpetkov@...>
Cc: Andy Whitcroft <apw@...>, <linux-kernel@...>, Jeremy Fitzhardinge <jeremy@...>
Date: Sunday, April 29, 2007 - 5:24 am

On Sun, 29 Apr 2007 08:50:49 +0200 Borislav Petkov <bbpetkov@yahoo.de> wrote:


I ended up doing the below.

It's better to make this a per-compiler-version thing: later versions of
gcc might need different tricks, or might provide __attribute__((stfu)) or
whatever.

Plus I don't know if the x=x trick is needed on the intel compiler, nor if
it even works, so I left ICC alone.




From: Borislav Petkov <bbpetkov@yahoo.de>

Introduce a macro for suppressing gcc from generating a warning about a
probable uninitialized state of a variable.

Example:

-	spinlock_t *ptl;
+	spinlock_t *uninitialized_var(ptl);

Not a happy solution, but those warnings are obnoxious.

- Using the usual pointlessly-set-it-to-zero approach wastes several
  bytes of text.

- Using a macro means we can (hopefully) do something else if gcc changes
  cause the `x = x' hack to stop working

- Using a macro means that people who are worried about hiding true bugs
  can easily turn it off.

Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 include/linux/compiler-gcc3.h  |    6 ++++++
 include/linux/compiler-gcc4.h  |    6 ++++++
 include/linux/compiler-intel.h |    2 ++
 3 files changed, 14 insertions(+)

diff -puN include/linux/compiler-gcc3.h~add-unitialized_var-macro-for-suppressing-gcc-warnings include/linux/compiler-gcc3.h
--- a/include/linux/compiler-gcc3.h~add-unitialized_var-macro-for-suppressing-gcc-warnings
+++ a/include/linux/compiler-gcc3.h
@@ -13,4 +13,10 @@
 #define __must_check		__attribute__((warn_unused_result))
 #endif
 
+/*
+ * A trick to suppress uninitialized variable warning without generating any
+ * code
+ */
+#define uninitialized_var(x) x = x
+
 #define __always_inline		inline __attribute__((always_inline))
diff -puN include/linux/compiler-gcc4.h~add-unitialized_var-macro-for-suppressing-gcc-warnings include/linux/compiler-gcc4.h
--- a/include/linux/compiler-gcc4.h~add-unitialized_var-macro-for-suppressing-gcc-warnings
+++ a/include/linux/compiler-gcc4.h
@@ -16,3 +16,9 @@
 #define __must_check 		__attribute__((warn_unused_result))
 #define __compiler_offsetof(a,b) __builtin_offsetof(a,b)
 #define __always_inline		inline __attribute__((always_inline))
+
+/*
+ * A trick to suppress uninitialized variable warning without generating any
+ * code
+ */
+#define uninitialized_var(x) x = x
diff -puN include/linux/compiler-intel.h~add-unitialized_var-macro-for-suppressing-gcc-warnings include/linux/compiler-intel.h
--- a/include/linux/compiler-intel.h~add-unitialized_var-macro-for-suppressing-gcc-warnings
+++ a/include/linux/compiler-intel.h
@@ -22,3 +22,5 @@
     (typeof(ptr)) (__ptr + (off)); })
 
 #endif
+
+#define uninitialized_var(x) x
_

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
2.6.21-rc7-mm2, Andrew Morton, (Thu Apr 26, 1:57 am)
Re: 2.6.21-rc7-mm2 hangs in boot, Randy Dunlap, (Mon Apr 30, 1:01 am)
Re: 2.6.21-rc7-mm2 hangs in boot, Andrew Morton, (Mon Apr 30, 1:23 am)
Re: 2.6.21-rc7-mm2 hangs in boot, Randy Dunlap, (Mon Apr 30, 11:16 am)
Re: 2.6.21-rc7-mm2 hangs in boot (netconsole), Randy Dunlap, (Mon Apr 30, 7:51 pm)
Re: 2.6.21-rc7-mm2 hangs in boot (netconsole), Andrew Morton, (Mon Apr 30, 8:12 pm)
Re: 2.6.21-rc7-mm2 hangs in boot (netconsole), Randy Dunlap, (Mon Apr 30, 8:45 pm)
Re: 2.6.21-rc7-mm2 hangs in boot (netconsole), Andrew Morton, (Mon Apr 30, 9:08 pm)
Re: 2.6.21-rc7-mm2 hangs in boot (netconsole), Andi Kleen, (Mon Apr 30, 11:43 pm)
Re: 2.6.21-rc7-mm2 hangs in boot (netconsole), Randy Dunlap, (Tue May 1, 1:16 am)
Re: 2.6.21-rc7-mm2 hangs in boot (netconsole), Andi Kleen, (Tue May 1, 2:22 am)
Re: 2.6.21-rc7-mm2 hangs in boot (netconsole), Randy Dunlap, (Tue May 1, 12:22 pm)
Re: 2.6.21-rc7-mm2 hangs in boot (netconsole), Randy Dunlap, (Tue May 1, 1:26 pm)
Re: 2.6.21-rc7-mm2 hangs in boot (netconsole), Andrew Morton, (Tue May 1, 1:23 am)
Re: 2.6.21-rc7-mm2 hangs in boot (netconsole), Andi Kleen, (Tue May 1, 2:24 am)
Re: 2.6.21-rc7-mm2 hangs in boot (netconsole), Andrew Morton, (Tue May 1, 1:38 am)
Re: 2.6.21-rc7-mm2 hangs in boot (netconsole), Randy Dunlap, (Tue May 1, 12:15 pm)
Re: 2.6.21-rc7-mm2, Dan Kruchinin, (Sun Apr 29, 3:19 pm)
Re: 2.6.21-rc7-mm2, Andrew Morton, (Sun Apr 29, 3:48 pm)
[-mm patch] MMC: make tifm_sd_set_dma_data() static, Adrian Bunk, (Sat Apr 28, 3:19 pm)
Re: [-mm patch] MMC: make tifm_sd_set_dma_data() static, Pierre Ossman, (Tue May 1, 10:14 am)
Re: [-mm patch] make drivers/misc/thinkpad_acpi:fan_mutex st..., Henrique de Moraes Holschuh..., (Sat Apr 28, 3:58 pm)
Re: [-mm patch] make drivers/misc/thinkpad_acpi:fan_mutex st..., Henrique de Moraes Holschuh..., (Sun Apr 29, 12:09 am)
2.6.21-rc7-mm2 breaks 'lvm vgscan'., , (Thu Apr 26, 10:31 pm)
Re: 2.6.21-rc7-mm2 breaks 'lvm vgscan'., Andrew Morton, (Thu Apr 26, 10:55 pm)
[-mm patch] unexport highlevel_host_reset, Adrian Bunk, (Thu Apr 26, 7:47 pm)
Re: [-mm patch] unexport highlevel_host_reset, Stefan Richter, (Thu Apr 26, 8:16 pm)
Re: [PATCH] mm/memory.c: remove warning from an uninitialize..., Andrew Morton, (Sun Apr 29, 5:24 am)
Re: [PATCH] mm/memory.c: remove warning from an uninitialize..., Jeremy Fitzhardinge, (Sat Apr 28, 3:03 am)
Re: [PATCH] mm/memory.c: remove warning from an uninitialize..., Jeremy Fitzhardinge, (Fri Apr 27, 8:27 pm)
Re: 2.6.21-rc7-mm2, Andy Whitcroft, (Thu Apr 26, 9:17 am)
Re: 2.6.21-rc7-mm2 -- PPC link failure, Andy Whitcroft, (Thu Apr 26, 9:41 am)
Re: 2.6.21-rc7-mm2 -- PPC link failure, Andy Whitcroft, (Thu Apr 26, 2:14 pm)
Re: 2.6.21-rc7-mm2 -- PPC link failure, Christoph Lameter, (Thu Apr 26, 2:27 pm)
Re: 2.6.21-rc7-mm2 -- PPC link failure, Andy Whitcroft, (Thu Apr 26, 2:40 pm)
Re: 2.6.21-rc7-mm2 -- PPC link failure, Christoph Lameter, (Thu Apr 26, 3:12 pm)
Re: 2.6.21-rc7-mm2 -- PPC link failure, Andy Whitcroft, (Thu Apr 26, 3:48 pm)
Re: 2.6.21-rc7-mm2 -- PPC link failure, Christoph Lameter, (Thu Apr 26, 4:23 pm)
Re: 2.6.21-rc7-mm2 -- PPC link failure, Andy Whitcroft, (Fri Apr 27, 12:55 pm)
Re: 2.6.21-rc7-mm2 -- PPC link failure, Christoph Lameter, (Fri Apr 27, 12:58 pm)
Re: 2.6.21-rc7-mm2 -- PPC link failure, Christoph Lameter, (Thu Apr 26, 2:49 pm)
Re: 2.6.21-rc7-mm2 -- x86_64 blade hard hangs, Andy Whitcroft, (Thu Apr 26, 8:30 am)
Re: 2.6.21-rc7-mm2 -- x86_64 blade hard hangs, Andi Kleen, (Thu Apr 26, 9:51 am)
Re: 2.6.21-rc7-mm2 -- x86_64 blade hard hangs, Mel Gorman, (Thu Apr 26, 9:33 am)
Re: 2.6.21-rc7-mm2 -- x86_64 blade hard hangs, Mel Gorman, (Thu Apr 26, 10:46 am)
Re: 2.6.21-rc7-mm2 -- x86_64 blade hard hangs, Mel Gorman, (Thu Apr 26, 1:40 pm)
Re: 2.6.21-rc7-mm2 -- x86_64 VDSO compile error, Andy Whitcroft, (Thu Apr 26, 8:16 am)
Re: 2.6.21-rc7-mm2 -- x86_64 VDSO compile error, Mel Gorman, (Thu Apr 26, 9:27 am)
Re: 2.6.21-rc7-mm2 -- x86_64 VDSO compile error II, Andi Kleen, (Thu Apr 26, 10:13 am)
Re: 2.6.21-rc7-mm2 -- x86_64 VDSO compile error II, Mel Gorman, (Thu Apr 26, 10:39 am)
Re: 2.6.21-rc7-mm2 -- x86_64 VDSO compile error II, Mel Gorman, (Thu Apr 26, 11:20 am)
Re: 2.6.21-rc7-mm2 -- x86_64 VDSO compile error II, Andi Kleen, (Thu Apr 26, 11:24 am)
Re: 2.6.21-rc7-mm2 -- x86_64 VDSO compile error II, Mel Gorman, (Thu Apr 26, 11:45 am)
Re: 2.6.21-rc7-mm2 -- x86_64 VDSO compile error II, Andi Kleen, (Thu Apr 26, 8:39 pm)
Re: 2.6.21-rc7-mm2 -- x86_64 VDSO compile error II, Mel Gorman, (Fri Apr 27, 4:59 am)
Re: 2.6.21-rc7-mm2 -- x86_64 VDSO compile error, Andi Kleen, (Thu Apr 26, 10:11 am)
Re: 2.6.21-rc7-mm2 -- x86_64 VDSO compile error, Mel Gorman, (Thu Apr 26, 10:31 am)
Re: 2.6.21-rc7-mm2, Gabriel C, (Thu Apr 26, 7:47 am)
Re: 2.6.21-rc7-mm2, Andrew Morton, (Thu Apr 26, 4:37 pm)
Re: 2.6.21-rc7-mm2, Timur Tabi, (Thu Apr 26, 4:57 pm)
Re: 2.6.21-rc7-mm2, Andrew Morton, (Thu Apr 26, 5:33 pm)
Re: 2.6.21-rc7-mm2, Gabriel C, (Thu Apr 26, 5:13 pm)
Re: 2.6.21-rc7-mm2, Randy Dunlap, (Thu Apr 26, 4:46 pm)
Re: 2.6.21-rc7-mm2, Geert Uytterhoeven, (Sun Apr 29, 4:05 am)