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 '-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.
This commit is contained in:
Assaf Gordon committed 2021-01-05 17:02:41 -07:00
1 parent 71de42fd34
commit fb0c57d55e
1 file changed
+3
+3
View File
@@ -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);
}