enable -Wformat-nonliteral for linux and equivalent for windows compilers

Whitelist all the verified existing triggers:
makedefs.c: In function ‘name_file’
attrib.c: one compiler balks at a ? b : c for fmtstring
cmd.c: In function ‘extcmd_via_menu’
cmd.c: In function ‘wiz_levltyp_legend’
do.c: In function ‘goto_level’
do_name.c: In function ‘coord_desc’
dungeon.c: In function ‘overview_stats’
eat.c:  one compiler balks at a ? b : c for fmtstring
end.c:  one compiler balks at a ? b : c for fmtstring
engrave.c: In function ‘engr_stats’
hack:c one compiler balks at a ? b : c for fmtstring
hacklib.c: one compiler balks at a ? b : c for fmtstring
insight.c: one compiler balks at a ? b : c for fmtstring
invent.c: In function ‘let_to_name’
light.c: In function ‘light_stats’
mhitm.c: In function ‘missmm’
options.c: In function ‘handler_symset’
options.c: In function ‘basic_menu_colors’
options.c: In function ‘optfn_o_autopickup_exceptions’
options.c: In function ‘optfn_o_menu_colors’
options.c: In function ‘optfn_o_message_types’
options.c: In function ‘optfn_o_status_cond’
options.c: In function ‘optfn_o_status_hilites’
options.c: In function ‘doset’
options.c: In function ‘doset_add_menu’
options.c: In function ‘show_menu_controls’
options.c: In function ‘handle_add_list_remove’
pager.c: In function ‘do_supplemental_info’
pager.c: In function ‘dohelp’
region.c: In function ‘region_stats’
rumors.c: sscanf usage
sounds.c: In function ‘domonnoise’
spell.c: In function ‘dospellmenu’
timeout.c: In function ‘timer_stats’
topten.c: In function ‘outentry’, fscanf, sscanf, fprintf usage
windows.c: In function ‘genl_status_update’
zap.c: one compiler balks at a ? b : c for fmtstring
win/curses/cursstat.c: In function ‘curses_status_update’
win/tty/wintty.c: In function ‘tty_status_update’
win/win32/mswproc.c: In function ‘mswin_status_update’
This commit is contained in:
nhmall
2021-02-02 19:03:12 -05:00
parent d79365c6b0
commit 5b1d668c44
32 changed files with 195 additions and 5 deletions
+17
View File
@@ -12,8 +12,11 @@
* When STDC_Pragma_AVAILABLE is not defined, these are defined as no-ops: * When STDC_Pragma_AVAILABLE is not defined, these are defined as no-ops:
* DISABLE_WARNING_UNREACHABLE_CODE * DISABLE_WARNING_UNREACHABLE_CODE
* DISABLE_WARNING_CONDEXPR_IS_CONSTANT * DISABLE_WARNING_CONDEXPR_IS_CONSTANT
* DISABLE_WARNING_FORMAT_NONLITERAL
* ... * ...
* RESTORE_WARNINGS * RESTORE_WARNINGS
* RESTORE_WARNING_CONDEXPR_IS_CONSTANT
* RESTORE_WARNING_FORMAT_NONLITERAL
* *
*/ */
@@ -34,8 +37,12 @@
#define DISABLE_WARNING_UNREACHABLE_CODE \ #define DISABLE_WARNING_UNREACHABLE_CODE \
_Pragma("clang diagnostic push") \ _Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wunreachable-code\"") _Pragma("clang diagnostic ignored \"-Wunreachable-code\"")
#define DISABLE_WARNING_FORMAT_NONLITERAL \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wformat-nonliteral\"")
#define DISABLE_WARNING_CONDEXPR_IS_CONSTANT #define DISABLE_WARNING_CONDEXPR_IS_CONSTANT
#define RESTORE_WARNING_CONDEXPR_IS_CONSTANT #define RESTORE_WARNING_CONDEXPR_IS_CONSTANT
#define RESTORE_WARNING_FORMAT_NONLITERAL _Pragma("clang diagnostic pop")
#define RESTORE_WARNINGS _Pragma("clang diagnostic pop") #define RESTORE_WARNINGS _Pragma("clang diagnostic pop")
#define STDC_Pragma_AVAILABLE #define STDC_Pragma_AVAILABLE
@@ -44,8 +51,12 @@
#define DISABLE_WARNING_UNREACHABLE_CODE \ #define DISABLE_WARNING_UNREACHABLE_CODE \
_Pragma("GCC diagnostic push") \ _Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wunreachable-code\"") _Pragma("GCC diagnostic ignored \"-Wunreachable-code\"")
#define DISABLE_WARNING_FORMAT_NONLITERAL \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wformat-nonliteral\"")
#define DISABLE_WARNING_CONDEXPR_IS_CONSTANT #define DISABLE_WARNING_CONDEXPR_IS_CONSTANT
#define RESTORE_WARNING_CONDEXPR_IS_CONSTANT #define RESTORE_WARNING_CONDEXPR_IS_CONSTANT
#define RESTORE_WARNING_FORMAT_NONLITERAL _Pragma("GCC diagnostic pop")
#define RESTORE_WARNINGS _Pragma("GCC diagnostic pop") #define RESTORE_WARNINGS _Pragma("GCC diagnostic pop")
#define STDC_Pragma_AVAILABLE #define STDC_Pragma_AVAILABLE
@@ -53,10 +64,14 @@
#define DISABLE_WARNING_UNREACHABLE_CODE \ #define DISABLE_WARNING_UNREACHABLE_CODE \
_Pragma("warning( push )") \ _Pragma("warning( push )") \
_Pragma("warning( disable : 4702 )") _Pragma("warning( disable : 4702 )")
#define DISABLE_WARNING_FORMAT_NONLITERAL \
_Pragma("warning( push )") \
_Pragma("warning( disable : 4774 )")
#define DISABLE_WARNING_CONDEXPR_IS_CONSTANT \ #define DISABLE_WARNING_CONDEXPR_IS_CONSTANT \
_Pragma("warning( push )") \ _Pragma("warning( push )") \
_Pragma("warning( disable : 4127 )") _Pragma("warning( disable : 4127 )")
#define RESTORE_WARNING_CONDEXPR_IS_CONSTANT _Pragma("warning( pop )") #define RESTORE_WARNING_CONDEXPR_IS_CONSTANT _Pragma("warning( pop )")
#define RESTORE_WARNING_FORMAT_NONLITERAL _Pragma("warning( pop )")
#define RESTORE_WARNINGS _Pragma("warning( pop )") #define RESTORE_WARNINGS _Pragma("warning( pop )")
#define STDC_Pragma_AVAILABLE #define STDC_Pragma_AVAILABLE
@@ -70,8 +85,10 @@
#if !defined(STDC_Pragma_AVAILABLE) #if !defined(STDC_Pragma_AVAILABLE)
#define DISABLE_WARNING_UNREACHABLE_CODE #define DISABLE_WARNING_UNREACHABLE_CODE
#define DISABLE_WARNING_FORMAT_NONLITERAL
#define DISABLE_WARNING_CONDEXPR_IS_CONSTANT #define DISABLE_WARNING_CONDEXPR_IS_CONSTANT
#define RESTORE_WARNING_CONDEXPR_IS_CONSTANT #define RESTORE_WARNING_CONDEXPR_IS_CONSTANT
#define RESTORE_WARNING_FORMAT_NONLITERAL
#define RESTORE_WARNINGS #define RESTORE_WARNINGS
#endif #endif
+4
View File
@@ -799,6 +799,8 @@ is_innate(int propidx)
return FROM_NONE; return FROM_NONE;
} }
DISABLE_WARNING_FORMAT_NONLITERAL
char * char *
from_what(int propidx) /* special cases can have negative values */ from_what(int propidx) /* special cases can have negative values */
{ {
@@ -891,6 +893,8 @@ from_what(int propidx) /* special cases can have negative values */
return buf; return buf;
} }
RESTORE_WARNING_FORMAT_NONLITERAL
void void
adjabil(int oldlevel, int newlevel) adjabil(int oldlevel, int newlevel)
{ {
+17
View File
@@ -551,6 +551,8 @@ doextlist(void)
#if defined(TTY_GRAPHICS) || defined(CURSES_GRAPHICS) #if defined(TTY_GRAPHICS) || defined(CURSES_GRAPHICS)
#define MAX_EXT_CMD 200 /* Change if we ever have more ext cmds */ #define MAX_EXT_CMD 200 /* Change if we ever have more ext cmds */
DISABLE_WARNING_FORMAT_NONLITERAL
/* /*
* This is currently used only by the tty interface and is * This is currently used only by the tty interface and is
* controlled via runtime option 'extmenu'. (Most other interfaces * controlled via runtime option 'extmenu'. (Most other interfaces
@@ -692,6 +694,9 @@ extcmd_via_menu(void)
} }
return ret; return ret;
} }
RESTORE_WARNING_FORMAT_NONLITERAL
#endif /* TTY_GRAPHICS */ #endif /* TTY_GRAPHICS */
/* #monster command - use special monster ability while polymorphed */ /* #monster command - use special monster ability while polymorphed */
@@ -1457,6 +1462,8 @@ levltyp_to_name(int typ)
return NULL; return NULL;
} }
DISABLE_WARNING_FORMAT_NONLITERAL
/* explanation of base-36 output from wiz_map_levltyp() */ /* explanation of base-36 output from wiz_map_levltyp() */
static void static void
wiz_levltyp_legend(void) wiz_levltyp_legend(void)
@@ -1497,6 +1504,8 @@ wiz_levltyp_legend(void)
return; return;
} }
RESTORE_WARNING_FORMAT_NONLITERAL
DISABLE_WARNING_CONDEXPR_IS_CONSTANT DISABLE_WARNING_CONDEXPR_IS_CONSTANT
/* #wizsmell command - test usmellmon(). */ /* #wizsmell command - test usmellmon(). */
@@ -1541,6 +1550,8 @@ wiz_smell(void)
RESTORE_WARNING_CONDEXPR_IS_CONSTANT RESTORE_WARNING_CONDEXPR_IS_CONSTANT
DISABLE_WARNING_FORMAT_NONLITERAL
#define DEFAULT_TIMEOUT_INCR 30 #define DEFAULT_TIMEOUT_INCR 30
/* #wizinstrinsic command to set some intrinsics for testing */ /* #wizinstrinsic command to set some intrinsics for testing */
@@ -1695,6 +1706,8 @@ wiz_intrinsic(void)
return 0; return 0;
} }
RESTORE_WARNING_FORMAT_NONLITERAL
/* #wizrumorcheck command - verify each rumor access */ /* #wizrumorcheck command - verify each rumor access */
static int static int
wiz_rumor_check(void) wiz_rumor_check(void)
@@ -2589,6 +2602,8 @@ count_obj(struct obj *chain, long *total_count, long *total_size,
*total_size += size; *total_size += size;
} }
DISABLE_WARNING_FORMAT_NONLITERAL /* RESTORE_WARNING follows show_wiz_stats */
static void static void
obj_chain(winid win, const char *src, struct obj *chain, boolean force, obj_chain(winid win, const char *src, struct obj *chain, boolean force,
long *total_count, long *total_size) long *total_count, long *total_size)
@@ -2905,6 +2920,8 @@ wiz_show_stats(void)
return 0; return 0;
} }
RESTORE_WARNING_FORMAT_NONLITERAL
void void
sanity_check(void) sanity_check(void)
{ {
+4
View File
@@ -1232,6 +1232,8 @@ u_collide_m(struct monst *mtmp)
} }
} }
DISABLE_WARNING_FORMAT_NONLITERAL
void void
goto_level(d_level *newlevel, boolean at_stairs, boolean falling, boolean portal) goto_level(d_level *newlevel, boolean at_stairs, boolean falling, boolean portal)
{ {
@@ -1730,6 +1732,8 @@ goto_level(d_level *newlevel, boolean at_stairs, boolean falling, boolean portal
(void) pickup(1); (void) pickup(1);
} }
RESTORE_WARNING_FORMAT_NONLITERAL
/* usually called from goto_level(); might be called from Sting_effects() */ /* usually called from goto_level(); might be called from Sting_effects() */
void void
maybe_lvltport_feedback(void) maybe_lvltport_feedback(void)
+8
View File
@@ -96,6 +96,8 @@ getpos_help_keyxhelp(winid tmpwin, const char *k1, const char *k2, int gloc)
putstr(tmpwin, 0, sbuf); putstr(tmpwin, 0, sbuf);
} }
DISABLE_WARNING_FORMAT_NONLITERAL
/* the response for '?' help request in getpos() */ /* the response for '?' help request in getpos() */
static void static void
getpos_help(boolean force, const char *goal) getpos_help(boolean force, const char *goal)
@@ -225,6 +227,8 @@ getpos_help(boolean force, const char *goal)
destroy_nhwindow(tmpwin); destroy_nhwindow(tmpwin);
} }
RESTORE_WARNING_FORMAT_NONLITERAL
static int QSORTCALLBACK static int QSORTCALLBACK
cmp_coord_distu(const void *a, const void *b) cmp_coord_distu(const void *a, const void *b)
{ {
@@ -486,6 +490,8 @@ dxdy_to_dist_descr(int dx, int dy, boolean fulldir)
return buf; return buf;
} }
DISABLE_WARNING_FORMAT_NONLITERAL
/* coordinate formatting for 'whatis_coord' option */ /* coordinate formatting for 'whatis_coord' option */
char * char *
coord_desc(int x, int y, char *outbuf, char cmode) coord_desc(int x, int y, char *outbuf, char cmode)
@@ -527,6 +533,8 @@ coord_desc(int x, int y, char *outbuf, char cmode)
return outbuf; return outbuf;
} }
RESTORE_WARNING_FORMAT_NONLITERAL
static void static void
auto_describe(int cx, int cy) auto_describe(int cx, int cy)
{ {
+4
View File
@@ -2517,6 +2517,8 @@ load_mapseen(NHFILE *nhfp)
return load; return load;
} }
DISABLE_WARNING_FORMAT_NONLITERAL
/* to support '#stats' wizard-mode command */ /* to support '#stats' wizard-mode command */
void void
overview_stats(winid win, const char *statsfmt, overview_stats(winid win, const char *statsfmt,
@@ -2559,6 +2561,8 @@ overview_stats(winid win, const char *statsfmt,
*total_size += osize + bsize + asize; *total_size += osize + bsize + asize;
} }
RESTORE_WARNING_FORMAT_NONLITERAL
/* Remove all mapseen objects for a particular dnum. /* Remove all mapseen objects for a particular dnum.
* Useful during quest expulsion to remove quest levels. * Useful during quest expulsion to remove quest levels.
* [No longer deleted, just marked as unreachable. #overview will * [No longer deleted, just marked as unreachable. #overview will
+4
View File
@@ -915,6 +915,8 @@ givit(int type, register struct permonst *ptr)
} }
} }
DISABLE_WARNING_FORMAT_NONLITERAL
/* called after completely consuming a corpse */ /* called after completely consuming a corpse */
static void static void
cpostfx(int pm) cpostfx(int pm)
@@ -1142,6 +1144,8 @@ cpostfx(int pm)
return; return;
} }
RESTORE_WARNING_FORMAT_NONLITERAL
void void
violated_vegetarian(void) violated_vegetarian(void)
{ {
+5
View File
@@ -385,6 +385,9 @@ done_hangup(int sig)
#endif #endif
#endif /* NO_SIGNAL */ #endif /* NO_SIGNAL */
DISABLE_WARNING_FORMAT_NONLITERAL /* one compiler warns if the format
string is the result of a ? x : y */
void void
done_in_by(struct monst *mtmp, int how) done_in_by(struct monst *mtmp, int how)
{ {
@@ -504,6 +507,8 @@ done_in_by(struct monst *mtmp, int how)
return; return;
} }
RESTORE_WARNING_FORMAT_NONLITERAL
/* some special cases for overriding while-helpless reason */ /* some special cases for overriding while-helpless reason */
static const struct { static const struct {
int why, unmulti; int why, unmulti;
+4
View File
@@ -1234,6 +1234,8 @@ rest_engravings(NHFILE *nhfp)
} }
} }
DISABLE_WARNING_FORMAT_NONLITERAL
/* to support '#stats' wizard-mode command */ /* to support '#stats' wizard-mode command */
void void
engr_stats(const char *hdrfmt, char *hdrbuf, long *count, long *size) engr_stats(const char *hdrfmt, char *hdrbuf, long *count, long *size)
@@ -1248,6 +1250,8 @@ engr_stats(const char *hdrfmt, char *hdrbuf, long *count, long *size)
} }
} }
RESTORE_WARNING_FORMAT_NONLITERAL
void void
del_engr(register struct engr *ep) del_engr(register struct engr *ep)
{ {
+5
View File
@@ -572,6 +572,9 @@ ordin(int n) /* note: should be non-negative */
: (dd == 1) ? "st" : (dd == 2) ? "nd" : "rd"; : (dd == 1) ? "st" : (dd == 2) ? "nd" : "rd";
} }
DISABLE_WARNING_FORMAT_NONLITERAL /* one compiler complains about
result of ?: for format string */
/* make a signed digit string from a number */ /* make a signed digit string from a number */
char * char *
sitoa(int n) sitoa(int n)
@@ -582,6 +585,8 @@ sitoa(int n)
return buf; return buf;
} }
RESTORE_WARNING_FORMAT_NONLITERAL
/* return the sign of a number: -1, 0, or 1 */ /* return the sign of a number: -1, 0, or 1 */
int int
sgn(int n) sgn(int n)
+4
View File
@@ -2316,6 +2316,8 @@ dovanquished(void)
return 0; return 0;
} }
DISABLE_WARNING_FORMAT_NONLITERAL
/* #wizborn extended command */ /* #wizborn extended command */
int int
doborn(void) doborn(void)
@@ -2349,6 +2351,8 @@ doborn(void)
return 0; return 0;
} }
RESTORE_WARNING_FORMAT_NONLITERAL
/* high priests aren't unique but are flagged as such to simplify something */ /* high priests aren't unique but are flagged as such to simplify something */
#define UniqCritterIndx(mndx) ((mons[mndx].geno & G_UNIQ) \ #define UniqCritterIndx(mndx) ((mons[mndx].geno & G_UNIQ) \
&& mndx != PM_HIGH_CLERIC) && mndx != PM_HIGH_CLERIC)
+8
View File
@@ -2320,6 +2320,8 @@ prinv(const char *prefix, struct obj *obj, long quan)
xprname(obj, (char *) 0, obj_to_let(obj), TRUE, 0L, quan)); xprname(obj, (char *) 0, obj_to_let(obj), TRUE, 0L, quan));
} }
DISABLE_WARNING_FORMAT_NONLITERAL
char * char *
xprname(struct obj *obj, xprname(struct obj *obj,
const char *txt, /* text to print instead of obj */ const char *txt, /* text to print instead of obj */
@@ -2365,6 +2367,8 @@ xprname(struct obj *obj,
return li; return li;
} }
RESTORE_WARNING_FORMAT_NONLITERAL
/* the 'i' command */ /* the 'i' command */
int int
ddoinv(void) ddoinv(void)
@@ -3781,6 +3785,8 @@ static NEARDATA const char *names[] = {
static NEARDATA const char oth_symbols[] = { CONTAINED_SYM, '\0' }; static NEARDATA const char oth_symbols[] = { CONTAINED_SYM, '\0' };
static NEARDATA const char *oth_names[] = { "Bagged/Boxed items" }; static NEARDATA const char *oth_names[] = { "Bagged/Boxed items" };
DISABLE_WARNING_FORMAT_NONLITERAL
char * char *
let_to_name(char let, boolean unpaid, boolean showsym) let_to_name(char let, boolean unpaid, boolean showsym)
{ {
@@ -3823,6 +3829,8 @@ let_to_name(char let, boolean unpaid, boolean showsym)
return g.invbuf; return g.invbuf;
} }
RESTORE_WARNING_FORMAT_NONLITERAL
/* release the static buffer used by let_to_name() */ /* release the static buffer used by let_to_name() */
void void
free_invbuf(void) free_invbuf(void)
+4
View File
@@ -436,6 +436,8 @@ restore_light_sources(NHFILE *nhfp)
} }
} }
DISABLE_WARNING_FORMAT_NONLITERAL
/* to support '#stats' wizard-mode command */ /* to support '#stats' wizard-mode command */
void void
light_stats(const char *hdrfmt, char *hdrbuf, long *count, long *size) light_stats(const char *hdrfmt, char *hdrbuf, long *count, long *size)
@@ -450,6 +452,8 @@ light_stats(const char *hdrfmt, char *hdrbuf, long *count, long *size)
} }
} }
RESTORE_WARNING_FORMAT_NONLITERAL
/* Relink all lights that are so marked. */ /* Relink all lights that are so marked. */
void void
relink_light_sources(boolean ghostly) relink_light_sources(boolean ghostly)
+4
View File
@@ -71,6 +71,8 @@ pre_mm_attack(struct monst *magr, struct monst *mdef)
} }
} }
DISABLE_WARNING_FORMAT_NONLITERAL
static static
void void
missmm(register struct monst *magr, register struct monst *mdef, missmm(register struct monst *magr, register struct monst *mdef,
@@ -91,6 +93,8 @@ missmm(register struct monst *magr, register struct monst *mdef,
noises(magr, mattk); noises(magr, mattk);
} }
RESTORE_WARNING_FORMAT_NONLITERAL
/* /*
* fightm() -- fight some other monster * fightm() -- fight some other monster
* *
+18
View File
@@ -4849,6 +4849,8 @@ handler_whatis_filter(void)
return optn_ok; return optn_ok;
} }
DISABLE_WARNING_FORMAT_NONLITERAL
static int static int
handler_symset(int optidx) handler_symset(int optidx)
{ {
@@ -5026,6 +5028,8 @@ handler_symset(int optidx)
return optidx; return optidx;
} }
RESTORE_WARNING_FORMAT_NONLITERAL
static int static int
handler_autopickup_exception(void) handler_autopickup_exception(void)
{ {
@@ -6150,6 +6154,8 @@ match_str2attr(const char *str, boolean complain)
extern const char regex_id[]; /* from sys/share/<various>regex.{c,cpp} */ extern const char regex_id[]; /* from sys/share/<various>regex.{c,cpp} */
DISABLE_WARNING_FORMAT_NONLITERAL
/* True: temporarily replace menu color entries with a fake set of menu /* True: temporarily replace menu color entries with a fake set of menu
colors, { "light blue"=light_blue, "blue"=blue, "red"=red, &c }, that colors, { "light blue"=light_blue, "blue"=blue, "red"=red, &c }, that
illustrates most colors for use when the pick-a-color menu is rendered; illustrates most colors for use when the pick-a-color menu is rendered;
@@ -6203,6 +6209,8 @@ basic_menu_colors(boolean load_colors)
} }
} }
RESTORE_WARNING_FORMAT_NONLITERAL
int int
query_color(const char *prompt) query_color(const char *prompt)
{ {
@@ -6970,6 +6978,8 @@ static char fmtstr_doset[] = "%s%-15s [%s] ";
static char fmtstr_doset_tab[] = "%s\t[%s]"; static char fmtstr_doset_tab[] = "%s\t[%s]";
static char n_currently_set[] = "(%d currently set)"; static char n_currently_set[] = "(%d currently set)";
DISABLE_WARNING_FORMAT_NONLITERAL /* RESTORE is after show_menucontrols() */
static int static int
optfn_o_autopickup_exceptions(int optidx UNUSED, int req, boolean negated UNUSED, optfn_o_autopickup_exceptions(int optidx UNUSED, int req, boolean negated UNUSED,
char *opts, char *op UNUSED) char *opts, char *op UNUSED)
@@ -7340,6 +7350,7 @@ doset_add_menu(winid win, /* window to add to */
ATR_NONE, buf, MENU_ITEMFLAGS_NONE); ATR_NONE, buf, MENU_ITEMFLAGS_NONE);
} }
/* display keys for menu actions; used by cmd.c '?i' and pager.c '?k' */ /* display keys for menu actions; used by cmd.c '?i' and pager.c '?k' */
void void
show_menu_controls(winid win, boolean dolist) show_menu_controls(winid win, boolean dolist)
@@ -7431,6 +7442,9 @@ show_menu_controls(winid win, boolean dolist)
arg = ""; arg = "";
} }
} }
RESTORE_WARNING_FORMAT_NONLITERAL
static int static int
count_cond(void) count_cond(void)
{ {
@@ -7457,6 +7471,8 @@ count_apes(void)
return numapes; return numapes;
} }
DISABLE_WARNING_FORMAT_NONLITERAL
/* common to msg-types, menu-colors, autopickup-exceptions */ /* common to msg-types, menu-colors, autopickup-exceptions */
static int static int
handle_add_list_remove(const char *optname, int numtotal) handle_add_list_remove(const char *optname, int numtotal)
@@ -7504,6 +7520,8 @@ handle_add_list_remove(const char *optname, int numtotal)
return opt_idx; return opt_idx;
} }
RESTORE_WARNING_FORMAT_NONLITERAL
int int
dotogglepickup(void) dotogglepickup(void)
{ {
+8
View File
@@ -1425,6 +1425,8 @@ do_look(int mode, coord *click_cc)
return 0; return 0;
} }
DISABLE_WARNING_FORMAT_NONLITERAL /* RESTORE is after do_supplemental_info() */
static void static void
look_all(boolean nearby, /* True => within BOLTLIM, False => entire map */ look_all(boolean nearby, /* True => within BOLTLIM, False => entire map */
boolean do_mons) /* True => monsters, False => objects */ boolean do_mons) /* True => monsters, False => objects */
@@ -1600,6 +1602,8 @@ do_supplemental_info(char *name, struct permonst *pm, boolean without_asking)
} }
} }
RESTORE_WARNING_FORMAT_NONLITERAL
/* the '/' command */ /* the '/' command */
int int
dowhatis(void) dowhatis(void)
@@ -2098,6 +2102,8 @@ static const struct {
{ (void (*)(void)) 0, (char *) 0 } { (void (*)(void)) 0, (char *) 0 }
}; };
DISABLE_WARNING_FORMAT_NONLITERAL
/* the '?' command */ /* the '?' command */
int int
dohelp(void) dohelp(void)
@@ -2135,6 +2141,8 @@ dohelp(void)
return 0; return 0;
} }
RESTORE_WARNING_FORMAT_NONLITERAL
/* the 'V' command; also a choice for '?' */ /* the 'V' command; also a choice for '?' */
int int
dohistory(void) dohistory(void)
+4
View File
@@ -802,6 +802,8 @@ rest_regions(NHFILE* nhfp)
reset_region_mids(g.regions[i]); reset_region_mids(g.regions[i]);
} }
DISABLE_WARNING_FORMAT_NONLITERAL
/* to support '#stats' wizard-mode command */ /* to support '#stats' wizard-mode command */
void void
region_stats(const char* hdrfmt, char* hdrbuf, long* count, long* size) region_stats(const char* hdrfmt, char* hdrbuf, long* count, long* size)
@@ -825,6 +827,8 @@ region_stats(const char* hdrfmt, char* hdrbuf, long* count, long* size)
/* ? */ /* ? */
} }
RESTORE_WARNING_FORMAT_NONLITERAL
/* update monster IDs for region being loaded from bones; `ghostly' implied */ /* update monster IDs for region being loaded from bones; `ghostly' implied */
static void static void
reset_region_mids(NhRegion* reg) reset_region_mids(NhRegion* reg)
+8
View File
@@ -45,6 +45,8 @@ static void init_oracles(dlb *);
static void others_check(const char *ftype, const char *, winid *); static void others_check(const char *ftype, const char *, winid *);
static void couldnt_open_file(const char *); static void couldnt_open_file(const char *);
DISABLE_WARNING_FORMAT_NONLITERAL
static void static void
init_rumors(dlb* fp) init_rumors(dlb* fp)
{ {
@@ -70,6 +72,8 @@ init_rumors(dlb* fp)
} }
} }
RESTORE_WARNING_FORMAT_NONLITERAL
/* exclude_cookie is a hack used because we sometimes want to get rumors in a /* exclude_cookie is a hack used because we sometimes want to get rumors in a
* context where messages such as "You swallowed the fortune!" that refer to * context where messages such as "You swallowed the fortune!" that refer to
* cookies should not appear. This has no effect for true rumors since none * cookies should not appear. This has no effect for true rumors since none
@@ -272,6 +276,8 @@ rumor_check(void)
} }
} }
DISABLE_WARNING_FORMAT_NONLITERAL
/* 3.7: augments rumors_check(); test 'engrave' or 'epitaph' or 'bogusmon' */ /* 3.7: augments rumors_check(); test 'engrave' or 'epitaph' or 'bogusmon' */
static void static void
others_check(const char* ftype, const char* fname, winid* winptr) others_check(const char* ftype, const char* fname, winid* winptr)
@@ -373,6 +379,8 @@ others_check(const char* ftype, const char* fname, winid* winptr)
} }
} }
RESTORE_WARNING_FORMAT_NONLITERAL
/* Gets a random line of text from file 'fname', and returns it. /* Gets a random line of text from file 'fname', and returns it.
rng is the random number generator to use, and should act like rn2 does. */ rng is the random number generator to use, and should act like rn2 does. */
char * char *
+4
View File
@@ -548,6 +548,8 @@ mon_is_gecko(struct monst* mon)
return (boolean) (glyph_to_mon(glyph) == PM_GECKO); return (boolean) (glyph_to_mon(glyph) == PM_GECKO);
} }
DISABLE_WARNING_FORMAT_NONLITERAL
static int static int
domonnoise(register struct monst* mtmp) domonnoise(register struct monst* mtmp)
{ {
@@ -1048,6 +1050,8 @@ domonnoise(register struct monst* mtmp)
return 1; return 1;
} }
RESTORE_WARNING_FORMAT_NONLITERAL
/* #chat command */ /* #chat command */
int int
dotalk(void) dotalk(void)
+8
View File
@@ -337,6 +337,8 @@ book_cursed(struct obj* book)
stop_occupation(); stop_occupation();
} }
DISABLE_WARNING_FORMAT_NONLITERAL
static int static int
learn(void) learn(void)
{ {
@@ -435,6 +437,8 @@ learn(void)
return 0; return 0;
} }
RESTORE_WARNING_FORMAT_NONLITERAL
int int
study_book(register struct obj* spellbook) study_book(register struct obj* spellbook)
{ {
@@ -1628,6 +1632,8 @@ dovspell(void)
return 0; return 0;
} }
DISABLE_WARNING_FORMAT_NONLITERAL
static boolean static boolean
dospellmenu( dospellmenu(
const char *prompt, const char *prompt,
@@ -1712,6 +1718,8 @@ dospellmenu(
return FALSE; return FALSE;
} }
RESTORE_WARNING_FORMAT_NONLITERAL
static int static int
percent_success(int spell) percent_success(int spell)
{ {
+4
View File
@@ -2377,6 +2377,8 @@ restore_timers(NHFILE* nhfp, int range, long adjust)
} }
} }
DISABLE_WARNING_FORMAT_NONLITERAL
/* to support '#stats' wizard-mode command */ /* to support '#stats' wizard-mode command */
void void
timer_stats(const char* hdrfmt, char *hdrbuf, long *count, long *size) timer_stats(const char* hdrfmt, char *hdrbuf, long *count, long *size)
@@ -2391,6 +2393,8 @@ timer_stats(const char* hdrfmt, char *hdrbuf, long *count, long *size)
} }
} }
RESTORE_WARNING_FORMAT_NONLITERAL
/* reset all timers that are marked for reseting */ /* reset all timers that are marked for reseting */
void void
relink_timers(boolean ghostly) relink_timers(boolean ghostly)
+8
View File
@@ -205,6 +205,8 @@ discardexcess(FILE* rfile)
} while (c != '\n' && c != EOF); } while (c != '\n' && c != EOF);
} }
DISABLE_WARNING_FORMAT_NONLITERAL
static void static void
readentry(FILE* rfile, struct toptenentry* tt) readentry(FILE* rfile, struct toptenentry* tt)
{ {
@@ -320,6 +322,8 @@ writeentry(FILE* rfile, struct toptenentry* tt)
#endif #endif
} }
RESTORE_WARNING_FORMAT_NONLITERAL
#ifdef XLOGFILE #ifdef XLOGFILE
/* as tab is never used in eg. g.plname or death, no need to mangle those. */ /* as tab is never used in eg. g.plname or death, no need to mangle those. */
@@ -908,6 +912,8 @@ outheader(void)
topten_print(linebuf); topten_print(linebuf);
} }
DISABLE_WARNING_FORMAT_NONLITERAL
/* so>0: standout line; so=0: ordinary line */ /* so>0: standout line; so=0: ordinary line */
static void static void
outentry(int rank, struct toptenentry* t1, boolean so) outentry(int rank, struct toptenentry* t1, boolean so)
@@ -1069,6 +1075,8 @@ outentry(int rank, struct toptenentry* t1, boolean so)
topten_print(linebuf); topten_print(linebuf);
} }
RESTORE_WARNING_FORMAT_NONLITERAL
static int static int
score_wanted( score_wanted(
boolean current_ver, boolean current_ver,
+4
View File
@@ -888,6 +888,8 @@ genl_status_enablefield(int fieldidx, const char *nm, const char *fmt,
status_activefields[fieldidx] = enable; status_activefields[fieldidx] = enable;
} }
DISABLE_WARNING_FORMAT_NONLITERAL
/* call once for each field, then call with BL_FLUSH to output the result */ /* call once for each field, then call with BL_FLUSH to output the result */
void void
genl_status_update(int idx, genericptr_t ptr, int chg UNUSED, genl_status_update(int idx, genericptr_t ptr, int chg UNUSED,
@@ -1068,6 +1070,8 @@ genl_status_update(int idx, genericptr_t ptr, int chg UNUSED,
putmixed(WIN_STATUS, 0, newbot2); /* putmixed() due to GOLD glyph */ putmixed(WIN_STATUS, 0, newbot2); /* putmixed() due to GOLD glyph */
} }
RESTORE_WARNING_FORMAT_NONLITERAL
static struct window_procs dumplog_windowprocs_backup; static struct window_procs dumplog_windowprocs_backup;
static FILE *dumplog_file; static FILE *dumplog_file;
+4
View File
@@ -5256,6 +5256,8 @@ resist(struct monst *mtmp, char oclass, int damage, int tell)
#define MAXWISHTRY 5 #define MAXWISHTRY 5
DISABLE_WARNING_FORMAT_NONLITERAL
static void static void
wishcmdassist(int triesleft) wishcmdassist(int triesleft)
{ {
@@ -5313,6 +5315,8 @@ wishcmdassist(int triesleft)
destroy_nhwindow(win); destroy_nhwindow(win);
} }
RESTORE_WARNING_FORMAT_NONLITERAL
void void
makewish(void) makewish(void)
{ {
+1
View File
@@ -52,6 +52,7 @@ CFLAGS+=-Wimplicit-function-declaration
CFLAGS+=-Wimplicit-int CFLAGS+=-Wimplicit-int
CFLAGS+=-Wmissing-declarations CFLAGS+=-Wmissing-declarations
CFLAGS+=-Wmissing-prototypes CFLAGS+=-Wmissing-prototypes
CFLAGS+=-Wformat-nonliteral
ifeq "$(CCISCLANG)" "" ifeq "$(CCISCLANG)" ""
#gcc-specific here #gcc-specific here
CFLAGS+=-Wmissing-parameter-type CFLAGS+=-Wmissing-parameter-type
+3 -1
View File
@@ -678,8 +678,10 @@ scall =
# 4244 conversion possible loss of data # 4244 conversion possible loss of data
# 4245 conversion from 'char' to 'uchar', signed/unsigned mismatch # 4245 conversion from 'char' to 'uchar', signed/unsigned mismatch
# 4100 unreferenced formal parameter # 4100 unreferenced formal parameter
# 4774 format string is not a string literal (default is off at W4)
#
#cflags = $(cflags:-W3=-W4) -wd4131 -wd4820 -wd4706 -wd4244 -wd4245 -wd4100 #cflags = $(cflags:-W3=-W4) -wd4131 -wd4820 -wd4706 -wd4244 -wd4245 -wd4100
cflags = $(cflags:-W3=-W4) -wd4820 -wd4706 -wd4244 -wd4245 -wd4100 -wd4310 cflags = $(cflags:-W3=-W4) -wd4820 -wd4706 -wd4244 -wd4245 -wd4100 -wd4310 -w44774
!ENDIF !ENDIF
#More verbose warning output options below #More verbose warning output options below
+8
View File
@@ -337,6 +337,8 @@ do_makedefs(char *options)
static char namebuf[1000]; static char namebuf[1000];
DISABLE_WARNING_FORMAT_NONLITERAL
static char * static char *
name_file(const char* template, const char* tag) name_file(const char* template, const char* tag)
{ {
@@ -390,6 +392,8 @@ getfp(const char* template, const char* tag, const char* mode, int flg)
return rv; return rv;
} }
RESTORE_WARNING_FORMAT_NONLITERAL
static boolean debug = FALSE; static boolean debug = FALSE;
static FILE *inputfp; static FILE *inputfp;
@@ -972,6 +976,8 @@ do_rnd_access_file(const char* fname, const char* deflt_content)
return; return;
} }
DISABLE_WARNING_FORMAT_NONLITERAL
void void
do_rumors(void) do_rumors(void)
{ {
@@ -1064,6 +1070,8 @@ rumors_failure:
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
RESTORE_WARNING_FORMAT_NONLITERAL
void void
do_date(void) do_date(void)
{ {
+8
View File
@@ -136,6 +136,8 @@ curses_status_finish(void)
static int changed_fields = 0; static int changed_fields = 0;
DISABLE_WARNING_FORMAT_NONLITERAL
void void
curses_status_update(int fldidx, genericptr_t ptr, int chg UNUSED, int percent, curses_status_update(int fldidx, genericptr_t ptr, int chg UNUSED, int percent,
int color_and_attr, unsigned long *colormasks) int color_and_attr, unsigned long *colormasks)
@@ -202,6 +204,8 @@ curses_status_update(int fldidx, genericptr_t ptr, int chg UNUSED, int percent,
} }
} }
RESTORE_WARNING_FORMAT_NONLITERAL
static void static void
draw_status(void) draw_status(void)
{ {
@@ -981,6 +985,8 @@ curs_HPbar(char *text, /* pre-padded with trailing spaces if short */
extern const struct conditions_t conditions[]; /* botl.c */ extern const struct conditions_t conditions[]; /* botl.c */
extern int cond_idx[CONDITION_COUNT]; extern int cond_idx[CONDITION_COUNT];
DISABLE_WARNING_FORMAT_NONLITERAL
static void static void
curs_stat_conds( curs_stat_conds(
int vert_cond, /* 0 => horizontal, 1 => vertical */ int vert_cond, /* 0 => horizontal, 1 => vertical */
@@ -1104,6 +1110,8 @@ curs_stat_conds(
return; return;
} }
RESTORE_WARNING_FORMAT_NONLITERAL
/* status_update() sets up values for horizontal status; do vertical */ /* status_update() sets up values for horizontal status; do vertical */
void void
curs_vert_status_vals(int win_width) curs_vert_status_vals(int win_width)
+4
View File
@@ -3843,6 +3843,8 @@ tty_status_enablefield(int fieldidx, const char *nm, const char *fmt,
* See doc/window.doc for more details. * See doc/window.doc for more details.
*/ */
DISABLE_WARNING_FORMAT_NONLITERAL
void void
tty_status_update(int fldidx, genericptr_t ptr, int chg UNUSED, int percent, tty_status_update(int fldidx, genericptr_t ptr, int chg UNUSED, int percent,
int color, unsigned long *colormasks) int color, unsigned long *colormasks)
@@ -3964,6 +3966,8 @@ tty_status_update(int fldidx, genericptr_t ptr, int chg UNUSED, int percent,
return; return;
} }
RESTORE_WARNING_FORMAT_NONLITERAL
static int static int
make_things_fit(boolean force_update) make_things_fit(boolean force_update)
{ {
+5
View File
@@ -3072,6 +3072,9 @@ status_update(int fldindex, genericptr_t ptr, int chg, int percent, int color, u
longs telling which conditions should be displayed in each longs telling which conditions should be displayed in each
color and attriubte. color and attriubte.
*/ */
DISABLE_WARNING_FORMAT_NONLITERAL
void void
mswin_status_update(int idx, genericptr_t ptr, int chg, int percent, int color, unsigned long *condmasks) mswin_status_update(int idx, genericptr_t ptr, int chg, int percent, int color, unsigned long *condmasks)
{ {
@@ -3173,3 +3176,5 @@ mswin_status_update(int idx, genericptr_t ptr, int chg, int percent, int color,
} }
} }
RESTORE_WARNING_FORMAT_NONLITERAL
+2 -2
View File
@@ -29,7 +29,7 @@
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup> <ItemDefinitionGroup>
<ClCompile> <ClCompile>
<AdditionalOptions>/Gs /Oi- %(AdditionalOptions)</AdditionalOptions> <AdditionalOptions>/Gs /Oi- /w44774 %(AdditionalOptions)</AdditionalOptions>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<InlineFunctionExpansion>Default</InlineFunctionExpansion> <InlineFunctionExpansion>Default</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
@@ -43,7 +43,7 @@
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="@(Lua)"> <ClCompile Include="@(Lua)">
<DisableSpecificWarnings>4701;4702;4244;4310</DisableSpecificWarnings> <DisableSpecificWarnings>4701;4702;4244;4310;4774</DisableSpecificWarnings>
</ClCompile> </ClCompile>
<ClCompile Include="$(SrcDir)allmain.c" /> <ClCompile Include="$(SrcDir)allmain.c" />
<ClCompile Include="$(SrcDir)alloc.c" /> <ClCompile Include="$(SrcDir)alloc.c" />
+2 -2
View File
@@ -17,7 +17,7 @@
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup> <ItemDefinitionGroup>
<ClCompile> <ClCompile>
<AdditionalOptions>/Gs /Oi- %(AdditionalOptions)</AdditionalOptions> <AdditionalOptions>/Gs /Oi- /w44774 %(AdditionalOptions)</AdditionalOptions>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<OmitFramePointers>true</OmitFramePointers> <OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>$(WinWin32Dir);$(IncDir);$(SysWinntDir);$(SysShareDir);$(WinShareDir);$(LuaDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(WinWin32Dir);$(IncDir);$(SysWinntDir);$(SysShareDir);$(WinShareDir);$(LuaDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
@@ -37,7 +37,7 @@
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="@(Lua)"> <ClCompile Include="@(Lua)">
<DisableSpecificWarnings>4701;4702;4244;4310</DisableSpecificWarnings> <DisableSpecificWarnings>4701;4702;4244;4310;4774</DisableSpecificWarnings>
</ClCompile> </ClCompile>
<ClCompile Include="$(SrcDir)allmain.c" /> <ClCompile Include="$(SrcDir)allmain.c" />
<ClCompile Include="$(SrcDir)alloc.c" /> <ClCompile Include="$(SrcDir)alloc.c" />