>From 1407ea3095c3140836734e0d74cf55c611523aa9 Mon Sep 17 00:00:00 2001 From: Assaf Gordon Date: Sun, 3 Jan 2021 00:56:56 -0700 Subject: [PATCH] sed: silence -Wformat-nonoliteral warning GCC compilation fails with: sed/compile.c:206:3: error: format not a string literal, argument types not checked [-Werror=format-nonliteral] sprintf (unknown_cmd, msg, ch); ^~~~~~~ While there is suppression of "-Wformat-nonliteral" in configure.ac, it later uses '-Wformat=2' which turns "-Wformat-nonliteral" on. * sed/compile.c (bad_command): Add explicit "#pragma GCC ... ignore". The format string is fixed and known ahead of time. --- sed/compile.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sed/compile.c b/sed/compile.c index fe33e43..6d12f74 100644 --- a/sed/compile.c +++ b/sed/compile.c @@ -203,7 +203,10 @@ bad_command (char ch) { const char *msg = _(UNKNOWN_CMD); char *unknown_cmd = xmalloc (strlen (msg)); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-nonliteral" sprintf (unknown_cmd, msg, ch); +#pragma GCC diagnostic pop bad_prog (unknown_cmd); } -- 2.20.1