diff mbox series

[OpenWrt-Devel,libubox,02/20] blobmsg/ulog: fix format string compiler warnings

Message ID 20191219215836.21773-3-ynezz@true.cz
State Accepted
Delegated to: Petr Štetiar
Headers show
Series tests, fuzzing, fixes and improvements | expand

Commit Message

Petr Štetiar Dec. 19, 2019, 9:58 p.m. UTC
Fixes following compiler warnings:

 blobmsg.c:242:39: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
 blobmsg.c:248:23: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
 ulog.c:100:18: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
 ulog.c:112:16: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
 ulog.c:117:20: error: format string is not a string literal [-Werror,-Wformat-nonliteral]

Signed-off-by: Petr Štetiar <ynezz@true.cz>
---
 blobmsg.c | 8 ++++----
 ulog.c    | 3 +++
 2 files changed, 7 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/blobmsg.c b/blobmsg.c
index a860483bfa7e..97e0c20575ff 100644
--- a/blobmsg.c
+++ b/blobmsg.c
@@ -230,8 +230,8 @@  blobmsg_open_nested(struct blob_buf *buf, const char *name, bool array)
 	return (void *)offset;
 }
 
-int
-blobmsg_vprintf(struct blob_buf *buf, const char *name, const char *format, va_list arg)
+__attribute__((format(printf, 3, 0)))
+int blobmsg_vprintf(struct blob_buf *buf, const char *name, const char *format, va_list arg)
 {
 	va_list arg2;
 	char cbuf;
@@ -251,8 +251,8 @@  blobmsg_vprintf(struct blob_buf *buf, const char *name, const char *format, va_l
 	return ret;
 }
 
-int
-blobmsg_printf(struct blob_buf *buf, const char *name, const char *format, ...)
+__attribute__((format(printf, 3, 4)))
+int blobmsg_printf(struct blob_buf *buf, const char *name, const char *format, ...)
 {
 	va_list ap;
 	int ret;
diff --git a/ulog.c b/ulog.c
index b7300e720d21..05946a0c3521 100644
--- a/ulog.c
+++ b/ulog.c
@@ -87,6 +87,7 @@  static void ulog_defaults(void)
 	_ulog_initialized = 1;
 }
 
+__attribute__((format(printf, 2, 0)))
 static void ulog_kmsg(int priority, const char *fmt, va_list ap)
 {
 	FILE *kmsg;
@@ -102,6 +103,7 @@  static void ulog_kmsg(int priority, const char *fmt, va_list ap)
 	}
 }
 
+__attribute__((format(printf, 2, 0)))
 static void ulog_stdio(int priority, const char *fmt, va_list ap)
 {
 	FILE *out = stderr;
@@ -112,6 +114,7 @@  static void ulog_stdio(int priority, const char *fmt, va_list ap)
 	vfprintf(out, fmt, ap);
 }
 
+__attribute__((format(printf, 2, 0)))
 static void ulog_syslog(int priority, const char *fmt, va_list ap)
 {
 	vsyslog(priority, fmt, ap);