From: nhmall Date: Mon, 7 Feb 2022 14:16:31 +0000 (-0500) Subject: fix two reported warnings with SERVER_ADMIN_MSG defined X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=96c71660c61c39fa399af3aba0bcbd403020c87d;p=nethack fix two reported warnings with SERVER_ADMIN_MSG defined Report stated a -Wformat-nonliteral at line 612, and a -Wformat-security at line 614 I was only seeing the latter, so I added the former to the flags in sys/unix/hints/include/compiler.370. Some compiler versions have that warning on by default internally and others don't. If the format string isn't a string literal, there's no inteference with printf argument checking because that only operates on string literals. --- diff --git a/src/mail.c b/src/mail.c index 87ff8ada0..417f88a15 100644 --- a/src/mail.c +++ b/src/mail.c @@ -559,6 +559,9 @@ ckmailstatus(void) } #if defined(SIMPLE_MAIL) || defined(SERVER_ADMIN_MSG) + +DISABLE_WARNING_FORMAT_NONLITERAL + void read_simplemail(char *mbox, boolean adminmsg) { @@ -611,7 +614,7 @@ read_simplemail(char *mbox, boolean adminmsg) pline(msgfrom, curline); if (adminmsg) - verbalize(msg); + verbalize("%s", msg); else pline("It reads: \"%s\".", msg); @@ -642,6 +645,9 @@ read_simplemail(char *mbox, boolean adminmsg) if (!adminmsg) pline("It appears to be all gibberish."); } + +RESTORE_WARNING_FORMAT_NONLITERAL + #endif /* SIMPLE_MAIL */ void diff --git a/sys/unix/hints/include/compiler.370 b/sys/unix/hints/include/compiler.370 index 08a759e61..36bf438cc 100755 --- a/sys/unix/hints/include/compiler.370 +++ b/sys/unix/hints/include/compiler.370 @@ -56,6 +56,7 @@ CFLAGS+=-Wall -Wextra -Wno-missing-field-initializers \ CFLAGS+=-pedantic CFLAGS+=-Wmissing-declarations CFLAGS+=-Wunreachable-code +CFLAGS+=-Wformat-nonliteral # # the following are not allowed in C++ CFLAGS+=-Wimplicit