Skip to contentSkip to conversation

Mark inline functions as __maybe_unused

PATCH In review Behan Webster 2 participants 2 messages Jan 28, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Mark inline functions as __maybe_unused

clang warns if inline functions aren't used. By making them __maybe_unused there is no warning for either gcc nor clang.

---
 include/linux/compiler-gcc.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
include/linux/compiler-gcc.h +6 -6
index 02ae99e..c7b98fb 100644
@@ -53,14 +53,14 @@
  */
 #if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \
     !defined(CONFIG_OPTIMIZE_INLINING) || (__GNUC__ < 4)
-# define inline		inline		__attribute__((always_inline)) notrace
-# define __inline__	__inline__	__attribute__((always_inline)) notrace
-# define __inline	__inline	__attribute__((always_inline)) notrace
+# define inline		inline		__attribute__((always_inline)) notrace __maybe_unused
+# define __inline__	__inline__	__attribute__((always_inline)) notrace __maybe_unused
+# define __inline	__inline	__attribute__((always_inline)) notrace __maybe_unused
 #else
 /* A lot of inline functions can cause havoc with function tracing */
-# define inline		inline		notrace
-# define __inline__	__inline__	notrace
-# define __inline	__inline	notrace
+# define inline		inline		notrace __maybe_unused
+# define __inline__	__inline__	notrace __maybe_unused
+# define __inline	__inline	notrace __maybe_unused
 #endif
 
 #define __deprecated			__attribute__((deprecated))
Signature · 1 line
1.9.1
#1 lore raw
Quoted 2 lines · Behan Webster

clang warns if inline functions aren't used. By making them __maybe_unused there is no warning for either gcc nor clang.

Are you sure about that? I've never seen such behaviour from clang (or any other compiler), and it would truly be idiotic. If clang has taken to warning about unused inline functions, that's a regression that needs to be addressed in clang, not the kernel.

Signature · 2 lines
Måns Rullgård
[email protected]