option warnings
Fix a couple of warnings in options.c, and simplify feature_alert_opts()
in the process.
options.c:1126:30: warning: format string is not a string literal
(potentially insecure) [-Wformat-security]
config_error_add(buf);
^~~
options.c:1667:9: warning: unused variable 'i' [-Wunused-variable]
int i, c = NO_COLOR, a = ATR_NONE;
^
There are still a couple of warnings in files.c, but fixing them will
impinge open potential reversal of the CONFIG_ERROR_SECURE patch so
I've left them alone for the time being. The second one is because
VA_START() and/or VA_INIT() do more than just declare stuff; C99 doesn't
care, but for C90 (or pre-ANSI) the local variable should be declared
before them.
files.c:2816:12: warning: address of array 'buf' will always evaluate to
'true' [-Wpointer-bool-conversion]
(buf && buf[0]) ? buf : "Unknown error");
^~~ ~~
files.c:2799:10: warning: ISO C90 forbids mixing declarations and code
[-Wdeclaration-after-statement]
char buf[BUFSZ];
^
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 options.c $NHDT-Date: 1498078876 2017/06/21 21:01:16 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.288 $ */
|
||||
/* NetHack 3.6 options.c $NHDT-Date: 1505084668 2017/09/10 23:04:28 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.301 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -1107,26 +1107,22 @@ char *op;
|
||||
const char *optn;
|
||||
{
|
||||
char buf[BUFSZ];
|
||||
boolean rejectver = FALSE;
|
||||
unsigned long fnv = get_feature_notice_ver(op); /* version.c */
|
||||
|
||||
if (fnv == 0L)
|
||||
return 0;
|
||||
if (fnv > get_current_feature_ver())
|
||||
rejectver = TRUE;
|
||||
else
|
||||
flags.suppress_alert = fnv;
|
||||
if (rejectver) {
|
||||
if (fnv > get_current_feature_ver()) {
|
||||
if (!initial) {
|
||||
You_cant("disable new feature alerts for future versions.");
|
||||
} else {
|
||||
Sprintf(buf,
|
||||
"\n%s=%s Invalid reference to a future version ignored",
|
||||
optn, op);
|
||||
config_error_add(buf);
|
||||
config_error_add(
|
||||
"%s=%s Invalid reference to a future version ignored",
|
||||
optn, op);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
flags.suppress_alert = fnv;
|
||||
if (!initial) {
|
||||
Sprintf(buf, "%lu.%lu.%lu", FEATURE_NOTICE_VER_MAJ,
|
||||
FEATURE_NOTICE_VER_MIN, FEATURE_NOTICE_VER_PATCH);
|
||||
@@ -1664,7 +1660,7 @@ boolean
|
||||
add_menu_coloring(tmpstr)
|
||||
char *tmpstr;
|
||||
{
|
||||
int i, c = NO_COLOR, a = ATR_NONE;
|
||||
int c = NO_COLOR, a = ATR_NONE;
|
||||
char *tmps, *cs, *amp;
|
||||
char str[BUFSZ];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user