Silence compiler warnings for -Wformat-nonliteral
authorPeter Hutterer <peter.hutterer@who-t.net>
Thu, 22 Jul 2021 05:11:32 +0000 (15:11 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Thu, 22 Jul 2021 23:14:43 +0000 (23:14 +0000)
In the various logging functions where we need to modify the format
argument, disable the compiler warnings. Interestingly, GCC doesn't seem
to mind those but building with clang unleashes pages of warnings.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
src/evdev.c
src/evdev.h
tools/libinput-quirks.c
tools/libinput-record.c

index dc3eb43e024491aaef4082f5524d6a957e454b44..36c782f2ec7850661a47e66255ba6dd7393b7815 100644 (file)
@@ -2191,7 +2191,10 @@ libevdev_log_func(const struct libevdev *evdev,
 
        snprintf(fmt, sizeof(fmt), "%s%s", prefix, format);
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
        log_msg_va(libinput, pri, fmt, args);
+#pragma GCC diagnostic pop
 }
 
 static bool
index 0a4798f2dc6452e1429cc901bbab3075b8e2a070..0732063cb20beb2d9e943eb6cdb4e7160248af70 100644 (file)
@@ -775,7 +775,10 @@ evdev_log_msg(struct evdev_device *device,
                 format);
 
        va_start(args, format);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
        log_msg_va(evdev_libinput_context(device), priority, buf, args);
+#pragma GCC diagnostic pop
        va_end(args);
 
 }
@@ -810,7 +813,10 @@ evdev_log_msg_ratelimit(struct evdev_device *device,
                 format);
 
        va_start(args, format);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
        log_msg_va(evdev_libinput_context(device), priority, buf, args);
+#pragma GCC diagnostic pop
        va_end(args);
 
        if (state == RATELIMIT_THRESHOLD) {
index 434bca3fd098e8593199f50bde1b39ae31e3097b..173e5c22f65d631b7adce37f3758378e9d7c2fdd 100644 (file)
@@ -67,7 +67,10 @@ log_handler(struct libinput *this_is_null,
        }
 
        snprintf(buf, sizeof(buf), "%s: %s", prefix, format);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
        vfprintf(out, buf, args);
+#pragma GCC diagnostic pop
 }
 
 static void
index b12132fc8f9e5d8cd409620259401242e10a80fd..8ed14b5d695d989d974c2170d7f2f332ef4859fe 100644 (file)
@@ -210,7 +210,10 @@ iprintf(FILE *fp,
 
        snprintf(fmt, sizeof(fmt), "%s%s", &space[len - indent - 1], format);
        va_start(args, format);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
        rc = vfprintf(fp, fmt, args);
+#pragma GCC diagnostic pop
        va_end(args);
 
        assert(rc != -1 && (unsigned int)rc > indent);