Commit 9490991482a2091a828d997adbc088e24c310a4d
Committed by
Linus Torvalds
1 parent
a8127717cb
Exists in
master
and in
7 other branches
Add unitialized_var() macro for suppressing gcc warnings
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> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 4 changed files with 15 additions and 1 deletions Side-by-side Diff
include/linux/compiler-gcc3.h
... | ... | @@ -13,5 +13,11 @@ |
13 | 13 | #define __must_check __attribute__((warn_unused_result)) |
14 | 14 | #endif |
15 | 15 | |
16 | +/* | |
17 | + * A trick to suppress uninitialized variable warning without generating any | |
18 | + * code | |
19 | + */ | |
20 | +#define uninitialized_var(x) x = x | |
21 | + | |
16 | 22 | #define __always_inline inline __attribute__((always_inline)) |
include/linux/compiler-gcc4.h
... | ... | @@ -16,4 +16,10 @@ |
16 | 16 | #define __must_check __attribute__((warn_unused_result)) |
17 | 17 | #define __compiler_offsetof(a,b) __builtin_offsetof(a,b) |
18 | 18 | #define __always_inline inline __attribute__((always_inline)) |
19 | + | |
20 | +/* | |
21 | + * A trick to suppress uninitialized variable warning without generating any | |
22 | + * code | |
23 | + */ | |
24 | +#define uninitialized_var(x) x = x |
include/linux/compiler-intel.h
mm/memory.c