From c84e51870940311bb6ec67d8b192da1ce32cba8f Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Thu, 26 Jan 2023 14:53:47 +0100 Subject: *: no-warn pragmas for non-const format strings We do use non-constant/literal format strings in a few places for more or less valid reasons; put `ignored "-Wformat-nonliteral"` around those so we can have the warning enabled for everywhere else. Signed-off-by: David Lamparter --- lib/printf/vfprintf.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/printf/vfprintf.c') diff --git a/lib/printf/vfprintf.c b/lib/printf/vfprintf.c index 49fa2b718f..cc886834fa 100644 --- a/lib/printf/vfprintf.c +++ b/lib/printf/vfprintf.c @@ -504,14 +504,20 @@ reswitch: switch (ch) { fmt[4] = ch; fmt[5] = '\0'; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-nonliteral" snprintf(buf, sizeof(buf), fmt, prec, arg); +#pragma GCC diagnostic pop } else { double arg = GETARG(double); char fmt[5] = "%.*"; fmt[3] = ch; fmt[4] = '\0'; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-nonliteral" snprintf(buf, sizeof(buf), fmt, prec, arg); +#pragma GCC diagnostic pop } cp = buf; /* for proper padding */ -- cgit v1.2.3