[PATCH 2/2] compiler: fix __attribute__((format(printf, sandbox incompatibility

Ahmad Fatoum a.fatoum at pengutronix.de
Sun Feb 6 23:56:04 PST 2022

On sandbox, we define printf to barebox_printf for the non-sandbox
specific parts to avoid clashing with the libc-provided symbol. This is
substituted into the definition of __printf, leading to

  test/self/printf.c:37:1: warning: ‘barebox_printf’ is an
	unrecognized format function type [-Wformat=]

Avoid this by using the equivalent reserved keyword, which doesn't
clash. While at it, be a little future proof and do the same for scanf
as well.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
 include/linux/compiler_types.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index 9a5a6f0e8b17..aa9cbcac7740 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -201,8 +201,8 @@ struct ftrace_likely_data {
 #define __pure			__attribute__((pure))
 #define __aligned(x)		__attribute__((aligned(x)))
 #define __aligned_largest	__attribute__((aligned))
-#define __printf(a, b)		__attribute__((format(printf, a, b)))
-#define __scanf(a, b)		__attribute__((format(scanf, a, b)))
+#define __printf(a, b)		__attribute__((format(__printf__, a, b)))
+#define __scanf(a, b)		__attribute__((format(__scanf__, a, b)))
 #define __maybe_unused		__attribute__((unused))
 #define __always_unused		__attribute__((unused))
 #define __mode(x)		__attribute__((mode(x)))

More information about the barebox mailing list