Enable warning-free compilation even with -Wextra.

This commit is contained in:
Dianne Skoll
2019-11-04 16:35:14 -05:00
parent 74a6041760
commit 3095fd7e4a
10 changed files with 33 additions and 18 deletions

2
configure vendored
View File

@@ -3976,7 +3976,7 @@ fi
if test "$GCC" = yes; then if test "$GCC" = yes; then
CFLAGS="$CFLAGS -Wall -Wstrict-prototypes" CFLAGS="$CFLAGS -Wall -Wextra -Wstrict-prototypes"
fi fi
for ac_func in setenv unsetenv glob mbstowcs setlocale for ac_func in setenv unsetenv glob mbstowcs setlocale

View File

@@ -71,7 +71,7 @@ AC_FUNC_UTIME_NULL
AC_HEADER_TIME AC_HEADER_TIME
if test "$GCC" = yes; then if test "$GCC" = yes; then
CFLAGS="$CFLAGS -Wall -Wstrict-prototypes" CFLAGS="$CFLAGS -Wall -Wextra -Wstrict-prototypes"
fi fi
AC_CHECK_FUNCS(setenv unsetenv glob mbstowcs setlocale) AC_CHECK_FUNCS(setenv unsetenv glob mbstowcs setlocale)

View File

@@ -955,7 +955,7 @@ static int DoCalRem(ParsePtr p, int col)
return E_EOLN; return E_EOLN;
} }
if (trig.typ == SAT_TYPE) { if (trig.typ == SAT_TYPE) {
r=DoSatRemind(&trig, &tim, p); r=DoSatRemind(&trig, p);
if (r) { if (r) {
FreeTrig(&trig); FreeTrig(&trig);
if (r == E_EXPIRED) return OK; if (r == E_EXPIRED) return OK;

View File

@@ -68,7 +68,7 @@ int DoRem(ParsePtr p)
if (trig.typ == SAT_TYPE) { if (trig.typ == SAT_TYPE) {
PurgeEchoLine("%s\n", "#!P: Cannot purge SATISFY-type reminders"); PurgeEchoLine("%s\n", "#!P: Cannot purge SATISFY-type reminders");
PurgeEchoLine("%s\n", CurLine); PurgeEchoLine("%s\n", CurLine);
r=DoSatRemind(&trig, &tim, p); r=DoSatRemind(&trig, p);
if (r) { if (r) {
FreeTrig(&trig); FreeTrig(&trig);
if (r == E_EXPIRED) return OK; if (r == E_EXPIRED) return OK;
@@ -1019,7 +1019,7 @@ int ShouldTriggerReminder(Trigger *t, TimeTrig *tim, int jul, int *err)
/* Do the "satisfying..." remind calculation. */ /* Do the "satisfying..." remind calculation. */
/* */ /* */
/***************************************************************/ /***************************************************************/
int DoSatRemind(Trigger *trig, TimeTrig *tim, ParsePtr p) int DoSatRemind(Trigger *trig, ParsePtr p)
{ {
int iter, jul, r; int iter, jul, r;
Value v; Value v;

View File

@@ -798,7 +798,7 @@ static int Add(void)
v3.type = STR_TYPE; v3.type = STR_TYPE;
l1 = strlen(v1.v.str); l1 = strlen(v1.v.str);
l2 = strlen(v2.v.str); l2 = strlen(v2.v.str);
if (MaxStringLen && (l1 + l2 > MaxStringLen)) { if (MaxStringLen && (l1 + l2 > (size_t) MaxStringLen)) {
DestroyValue(v1); DestroyValue(v2); DestroyValue(v1); DestroyValue(v2);
return E_STRING_TOO_LONG; return E_STRING_TOO_LONG;
} }

View File

@@ -713,7 +713,7 @@ int DoIf(ParsePtr p)
int r; int r;
unsigned syndrome; unsigned syndrome;
if (NumIfs >= IF_NEST) return E_NESTED_IF; if ((size_t) NumIfs >= IF_NEST) return E_NESTED_IF;
if (ShouldIgnoreLine()) syndrome = IF_TRUE | BEFORE_ELSE; if (ShouldIgnoreLine()) syndrome = IF_TRUE | BEFORE_ELSE;
else { else {
@@ -794,7 +794,7 @@ int DoIfTrig(ParsePtr p)
int jul; int jul;
if (NumIfs >= IF_NEST) return E_NESTED_IF; if ((size_t) NumIfs >= IF_NEST) return E_NESTED_IF;
if (ShouldIgnoreLine()) syndrome = IF_TRUE | BEFORE_ELSE; if (ShouldIgnoreLine()) syndrome = IF_TRUE | BEFORE_ELSE;
else { else {
if ( (r=ParseRem(p, &trig, &tim, 1)) ) return r; if ( (r=ParseRem(p, &trig, &tim, 1)) ) return r;
@@ -1302,6 +1302,7 @@ void UTCToLocal(int utcdate, int utctime, int *locdate, int *loctime)
void SigIntHandler(int d) void SigIntHandler(int d)
{ {
UNUSED(d);
signal(SIGINT, SigIntHandler); signal(SIGINT, SigIntHandler);
GotSigInt(); GotSigInt();
exit(0); exit(0);

View File

@@ -9,6 +9,9 @@
/* */ /* */
/***************************************************************/ /***************************************************************/
/* Suppress unused variable warnings */
#define UNUSED(x) (void) x
/* Define a string assignment macro - be careful!!! */ /* Define a string assignment macro - be careful!!! */
#define STRSET(x, str) { if (x) free(x); (x) = StrDup(str); } #define STRSET(x, str) { if (x) free(x); (x) = StrDup(str); }
@@ -102,7 +105,7 @@ void DumpVarTable (void);
void DestroyVars (int all); void DestroyVars (int all);
int PreserveVar (char const *name); int PreserveVar (char const *name);
int DoPreserve (Parser *p); int DoPreserve (Parser *p);
int DoSatRemind (Trigger *trig, TimeTrig *tim, ParsePtr p); int DoSatRemind (Trigger *trig, ParsePtr p);
int DoMsgCommand (char const *cmd, char const *msg); int DoMsgCommand (char const *cmd, char const *msg);
int ParseNonSpaceChar (ParsePtr p, int *err, int peek); int ParseNonSpaceChar (ParsePtr p, int *err, int peek);
unsigned int HashVal (char const *str); unsigned int HashVal (char const *str);

View File

@@ -179,7 +179,7 @@ void HandleQueuedReminders(void)
while (TimeToSleep > 0L) { while (TimeToSleep > 0L) {
SleepTime = TimeToSleep; SleepTime = TimeToSleep;
if (Daemon > 0 && SleepTime > 60*Daemon) SleepTime = 60*Daemon; if (Daemon > 0 && SleepTime > (unsigned int) 60*Daemon) SleepTime = 60*Daemon;
/* Wake up once a minute to recalibrate sleep time in /* Wake up once a minute to recalibrate sleep time in
case of laptop hibernation */ case of laptop hibernation */

View File

@@ -62,7 +62,7 @@ char const *SmallCalLoc[] = {
"sbt", "sbt",
}; };
#define NUMSMALL (sizeof(SmallCalLoc)/sizeof(SmallCalLoc[0])) #define NUMSMALL ((int) (sizeof(SmallCalLoc)/sizeof(SmallCalLoc[0])))
char const *SmallLocation; char const *SmallLocation;
int SmallCol1, SmallCol2; int SmallCol1, SmallCol2;
@@ -669,7 +669,8 @@ void Init(int argc, char *argv[])
char const *s; char const *s;
char const *t; char const *t;
int i=1; int i=1;
int j; size_t j;
int k;
int offset; int offset;
PortraitMode = 1; PortraitMode = 1;
@@ -798,13 +799,13 @@ void Init(int argc, char *argv[])
case 'i': UseISO = 1; break; case 'i': UseISO = 1; break;
case 'c': j=(*s); case 'c': k=(*s);
if (!j) { if (!k) {
SmallLocation = SmallCalLoc[0]; SmallLocation = SmallCalLoc[0];
} else { } else {
j -= '0'; k -= '0';
if (j>=0 && j<NUMSMALL) { if (k>=0 && k<NUMSMALL) {
SmallLocation = SmallCalLoc[j]; SmallLocation = SmallCalLoc[k];
} else { } else {
SmallLocation = SmallCalLoc[0]; SmallLocation = SmallCalLoc[0];
} }

View File

@@ -37,6 +37,7 @@ typedef int (*SysVarFunc)(int, Value *);
static int trig_date_func(int do_set, Value *val) static int trig_date_func(int do_set, Value *val)
{ {
UNUSED(do_set);
val->type = DATE_TYPE; val->type = DATE_TYPE;
if (!LastTrigValid) { if (!LastTrigValid) {
val->v.val = 0; val->v.val = 0;
@@ -48,6 +49,7 @@ static int trig_date_func(int do_set, Value *val)
static int trig_day_func(int do_set, Value *val) static int trig_day_func(int do_set, Value *val)
{ {
int y, m, d; int y, m, d;
UNUSED(do_set);
val->type = INT_TYPE; val->type = INT_TYPE;
if (!LastTrigValid) { if (!LastTrigValid) {
val->v.val = -1; val->v.val = -1;
@@ -62,6 +64,7 @@ static int trig_day_func(int do_set, Value *val)
static int trig_mon_func(int do_set, Value *val) static int trig_mon_func(int do_set, Value *val)
{ {
int y, m, d; int y, m, d;
UNUSED(do_set);
val->type = INT_TYPE; val->type = INT_TYPE;
if (!LastTrigValid) { if (!LastTrigValid) {
val->v.val = -1; val->v.val = -1;
@@ -76,6 +79,7 @@ static int trig_mon_func(int do_set, Value *val)
static int trig_year_func(int do_set, Value *val) static int trig_year_func(int do_set, Value *val)
{ {
int y, m, d; int y, m, d;
UNUSED(do_set);
val->type = INT_TYPE; val->type = INT_TYPE;
if (!LastTrigValid) { if (!LastTrigValid) {
val->v.val = -1; val->v.val = -1;
@@ -90,6 +94,7 @@ static int trig_year_func(int do_set, Value *val)
static int trig_wday_func(int do_set, Value *val) static int trig_wday_func(int do_set, Value *val)
{ {
val->type = INT_TYPE; val->type = INT_TYPE;
UNUSED(do_set);
if (!LastTrigValid) { if (!LastTrigValid) {
val->v.val = -1; val->v.val = -1;
return OK; return OK;
@@ -101,6 +106,7 @@ static int trig_wday_func(int do_set, Value *val)
static int today_date_func(int do_set, Value *val) static int today_date_func(int do_set, Value *val)
{ {
UNUSED(do_set);
val->type = DATE_TYPE; val->type = DATE_TYPE;
val->v.val = JulianToday; val->v.val = JulianToday;
return OK; return OK;
@@ -108,6 +114,7 @@ static int today_date_func(int do_set, Value *val)
static int today_day_func(int do_set, Value *val) static int today_day_func(int do_set, Value *val)
{ {
int y, m, d; int y, m, d;
UNUSED(do_set);
val->type = INT_TYPE; val->type = INT_TYPE;
FromJulian(JulianToday, &y, &m, &d); FromJulian(JulianToday, &y, &m, &d);
val->v.val = d; val->v.val = d;
@@ -117,6 +124,7 @@ static int today_day_func(int do_set, Value *val)
static int today_mon_func(int do_set, Value *val) static int today_mon_func(int do_set, Value *val)
{ {
int y, m, d; int y, m, d;
UNUSED(do_set);
val->type = INT_TYPE; val->type = INT_TYPE;
FromJulian(JulianToday, &y, &m, &d); FromJulian(JulianToday, &y, &m, &d);
val->v.val = m+1; val->v.val = m+1;
@@ -126,6 +134,7 @@ static int today_mon_func(int do_set, Value *val)
static int today_year_func(int do_set, Value *val) static int today_year_func(int do_set, Value *val)
{ {
int y, m, d; int y, m, d;
UNUSED(do_set);
val->type = INT_TYPE; val->type = INT_TYPE;
FromJulian(JulianToday, &y, &m, &d); FromJulian(JulianToday, &y, &m, &d);
val->v.val = y; val->v.val = y;
@@ -134,6 +143,7 @@ static int today_year_func(int do_set, Value *val)
static int today_wday_func(int do_set, Value *val) static int today_wday_func(int do_set, Value *val)
{ {
UNUSED(do_set);
val->type = INT_TYPE; val->type = INT_TYPE;
val->v.val = (JulianToday + 1) % 7; val->v.val = (JulianToday + 1) % 7;
return OK; return OK;
@@ -748,7 +758,7 @@ static SysVar *FindSysVar(char const *name)
/***************************************************************/ /***************************************************************/
void DumpSysVarByName(char const *name) void DumpSysVarByName(char const *name)
{ {
int i; size_t i;
SysVar *v; SysVar *v;
if (!name || !*name) { if (!name || !*name) {