]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic/log: fix _printf_ annotation on log_object_internalv
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 20 Apr 2017 18:09:47 +0000 (14:09 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 20 Apr 2017 18:42:43 +0000 (14:42 -0400)
Fixup for 4b58153dd22172d817055d2a09a0cdf3f4bd9db3.

I saw this because of a clang warning. With gcc the -Wformat-nonliteral warning
doesn't seem to work as expected.

In two places, a string constructed with strjoina is used as the pattern. This
is safe, because we're taking a pattern which was already marked with _printf_
and prepending a known value to it.  Those places are marked with #pragma to
silence the warning.

src/basic/log.h
src/core/selinux-access.c
src/locale/localed.c

index 72714e02e5625992241e271537dd9041af0c909a..e578258114c15f344989c8a5adedf945b9f0dd09 100644 (file)
@@ -115,7 +115,7 @@ int log_object_internalv(
                 const char *extra_field,
                 const char *extra,
                 const char *format,
-                va_list ap) _printf_(9,0);
+                va_list ap) _printf_(10,0);
 
 int log_struct_internal(
                 int level,
index 2b96a9551b335a2db8b5698610545e7e50c46895..0f8a2d68e29e6de27a4559e915a27ea98cb4e06d 100644 (file)
@@ -135,7 +135,12 @@ _printf_(2, 3) static int log_callback(int type, const char *fmt, ...) {
         fmt2 = strjoina("selinux: ", fmt);
 
         va_start(ap, fmt);
-        log_internalv(LOG_AUTH | callback_type_to_priority(type), 0, __FILE__, __LINE__, __FUNCTION__, fmt2, ap);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+        log_internalv(LOG_AUTH | callback_type_to_priority(type),
+                      0, __FILE__, __LINE__, __FUNCTION__,
+                      fmt2, ap);
+#pragma GCC diagnostic pop
         va_end(ap);
 
         return 0;
index 1cb049e74af4596e9227e3dd48c62662f49905fc..b4798d674c76119b0f2cfe3fa38d7e8dd24ce570 100644 (file)
@@ -436,7 +436,10 @@ static void log_xkb(struct xkb_context *ctx, enum xkb_log_level lvl, const char
         const char *fmt;
 
         fmt = strjoina("libxkbcommon: ", format);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
         log_internalv(LOG_DEBUG, 0, __FILE__, __LINE__, __func__, fmt, args);
+#pragma GCC diagnostic pop
 }
 
 #define LOAD_SYMBOL(symbol, dl, name)                                   \