panic: suppress gnu_printf warning
authorBaoquan He <bhe@redhat.com>
Sun, 7 Jan 2024 09:16:41 +0000 (17:16 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 22 Feb 2024 23:38:51 +0000 (15:38 -0800)
with GCC 13.2.1 and W=1, there's compiling warning like this:

kernel/panic.c: In function `__warn':
kernel/panic.c:676:17: warning: function `__warn' might be a candidate for `gnu_printf' format attribute [-Wsuggest-attribute=format]
  676 |                 vprintk(args->fmt, args->args);
      |                 ^~~~~~~

The normal __printf(x,y) adding can't fix it. So add workaround which
disables -Wsuggest-attribute=format to mute it.

Link: https://lkml.kernel.org/r/20240107091641.579849-1-bhe@redhat.com
Signed-off-by: Baoquan He <bhe@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
kernel/panic.c

index 2807639aab51d1f631fa834dd2c7e1472864b25f..d49b68184c563e34cfc1577d966d91cb0ff2411b 100644 (file)
@@ -666,8 +666,13 @@ void __warn(const char *file, int line, void *caller, unsigned taint,
                pr_warn("WARNING: CPU: %d PID: %d at %pS\n",
                        raw_smp_processor_id(), current->pid, caller);
 
+#pragma GCC diagnostic push
+#ifndef __clang__
+#pragma GCC diagnostic ignored "-Wsuggest-attribute=format"
+#endif
        if (args)
                vprintk(args->fmt, args->args);
+#pragma GCC diagnostic pop
 
        print_modules();