From 96a33d1afcd312a3a2a509819edf9799d24aac1c Mon Sep 17 00:00:00 2001
From: Mara Bos <m-ou.se@m-ou.se>
Date: Sat, 27 Oct 2018 10:58:12 +0200
Subject: [PATCH] Enable __attribute__((format)) on px4 logging functions.

This makes the compiler warn about invalid format strings.
---
 src/platforms/px4_log.h | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/platforms/px4_log.h b/src/platforms/px4_log.h
index dbadbcb46f..2a4a0d988e 100644
--- a/src/platforms/px4_log.h
+++ b/src/platforms/px4_log.h
@@ -141,8 +141,15 @@ __BEGIN_DECLS
 __EXPORT extern const char *__px4_log_level_str[_PX4_LOG_LEVEL_PANIC + 1];
 __EXPORT extern const char *__px4_log_level_color[_PX4_LOG_LEVEL_PANIC + 1];
 __EXPORT extern void px4_backtrace(void);
-__EXPORT void px4_log_modulename(int level, const char *moduleName, const char *fmt, ...);
-__EXPORT void px4_log_raw(int level, const char *fmt, ...);
+__EXPORT void px4_log_modulename(int level, const char *moduleName, const char *fmt, ...)
+__attribute__((format(printf, 3, 4)));
+__EXPORT void px4_log_raw(int level, const char *fmt, ...)
+__attribute__((format(printf, 2, 3)));
+
+#if __GNUC__
+// Allow empty format strings.
+#pragma GCC diagnostic ignored "-Wformat-zero-length"
+#endif
 
 __END_DECLS
 
-- 
GitLab