[U-Boot] [PATCH] env_callback.h: spl: mark callback as maybe_unused

Jeroen Hofstee jeroen at myspectrum.nl
Thu Jul 10 20:38:35 CEST 2014


When static inline is used in a header file the function
should preferably be inlined and if not possible made a
static function. When declared inside a c file there is a
static function, which might be inlined. Since SPL uses a
define to declare the static inline it becomes part of the
c file although it is declared in a header and clang will
warn that you have introduced unused static functions. Add
maybe_unused to prevent such warnings.

Signed-off-by: Jeroen Hofstee <jeroen at myspectrum.nl>
---
fixes warnings for clang like:

drivers/serial/serial.c:96:1: warning: unused function '_u_boot_env_noop_baudrate' [-Wunused-function]
U_BOOT_ENV_CALLBACK(baudrate, on_baudrate);
^
include/env_callback.h:63:21: note: expanded from macro 'U_BOOT_ENV_CALLBACK'
        static inline void _u_boot_env_noop_##name(void) \
                           ^
<scratch space>:63:1: note: expanded from here
_u_boot_env_noop_baudrate
^

common/console.c:59:1: warning: unused function '_u_boot_env_noop_console' [-Wunused-function]
U_BOOT_ENV_CALLBACK(console, on_console);
^
include/env_callback.h:63:21: note: expanded from macro 'U_BOOT_ENV_CALLBACK'
        static inline void _u_boot_env_noop_##name(void) \
                           ^
<scratch space>:91:1: note: expanded from here
_u_boot_env_noop_console
^
---
 include/env_callback.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/env_callback.h b/include/env_callback.h
index f90a7fa..ab4e115 100644
--- a/include/env_callback.h
+++ b/include/env_callback.h
@@ -60,7 +60,7 @@ void env_callback_init(ENTRY *var_entry);
  */
 #ifdef CONFIG_SPL_BUILD
 #define U_BOOT_ENV_CALLBACK(name, callback) \
-	static inline void _u_boot_env_noop_##name(void) \
+	static inline __maybe_unused void _u_boot_env_noop_##name(void) \
 	{ \
 		(void)callback; \
 	}
-- 
1.8.3.2



More information about the U-Boot mailing list