Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/games/gomoku gomoku: fix most lint warnings in -DDEBUG mode
details: https://anonhg.NetBSD.org/src/rev/31c02a929e44
branches: trunk
changeset: 366165:31c02a929e44
user: rillig <rillig%NetBSD.org@localhost>
date: Mon May 16 21:35:39 2022 +0000
description:
gomoku: fix most lint warnings in -DDEBUG mode
No binary change.
diffstat:
games/gomoku/bdisp.c | 8 ++++----
games/gomoku/main.c | 26 +++++++++++++++++---------
games/gomoku/pickmove.c | 29 +++++++++++++++--------------
3 files changed, 36 insertions(+), 27 deletions(-)
diffs (254 lines):
diff -r ab7ee610d63b -r 31c02a929e44 games/gomoku/bdisp.c
--- a/games/gomoku/bdisp.c Mon May 16 21:28:05 2022 +0000
+++ b/games/gomoku/bdisp.c Mon May 16 21:35:39 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bdisp.c,v 1.24 2022/05/16 20:57:01 rillig Exp $ */
+/* $NetBSD: bdisp.c,v 1.25 2022/05/16 21:35:39 rillig Exp $ */
/*
* Copyright (c) 1994
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)bdisp.c 8.2 (Berkeley) 5/3/95";
#else
-__RCSID("$NetBSD: bdisp.c,v 1.24 2022/05/16 20:57:01 rillig Exp $");
+__RCSID("$NetBSD: bdisp.c,v 1.25 2022/05/16 21:35:39 rillig Exp $");
#endif
#endif /* not lint */
@@ -203,9 +203,9 @@
for (i = 1; i < BSZ + 1; i++) {
sp = &board[i + j * (BSZ + 1)];
if (debug > 1 && sp->s_occ == EMPTY) {
- if (sp->s_flags & IFLAGALL)
+ if ((sp->s_flags & IFLAGALL) != 0)
c = '+';
- else if (sp->s_flags & CFLAGALL)
+ else if ((sp->s_flags & CFLAGALL) != 0)
c = '-';
else
c = '.';
diff -r ab7ee610d63b -r 31c02a929e44 games/gomoku/main.c
--- a/games/gomoku/main.c Mon May 16 21:28:05 2022 +0000
+++ b/games/gomoku/main.c Mon May 16 21:35:39 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.34 2022/05/16 21:02:18 rillig Exp $ */
+/* $NetBSD: main.c,v 1.35 2022/05/16 21:35:39 rillig Exp $ */
/*
* Copyright (c) 1994
@@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)main.c 8.4 (Berkeley) 5/4/95";
#else
-__RCSID("$NetBSD: main.c,v 1.34 2022/05/16 21:02:18 rillig Exp $");
+__RCSID("$NetBSD: main.c,v 1.35 2022/05/16 21:35:39 rillig Exp $");
#endif
#endif /* not lint */
@@ -84,7 +84,9 @@
static int readinput(FILE *);
static void misclog(const char *, ...) __printflike(1, 2);
static void quit(void) __dead;
-static void quitsig(int) __dead __unused;
+#if !defined(DEBUG)
+static void quitsig(int) __dead;
+#endif
int
main(int argc, char **argv)
@@ -367,6 +369,7 @@
/*
* Handle strange situations.
*/
+/* ARGSUSED */
void
whatsup(int signum)
{
@@ -390,10 +393,12 @@
goto top;
case 'q': /* conservative quit */
quit();
+ /* NOTREACHED */
case 'd': /* set debug level */
debug = input[1] - '0';
debuglog("Debug set to %d", debug);
sleep(1);
+ break;
case 'c':
break;
case 'b': /* back up a move */
@@ -409,7 +414,8 @@
stoc(pickmove(i)));
goto top;
case 'f': /* go forward a move */
- board[movelog[movenum - 1]].s_occ = movenum & 1 ? BLACK : WHITE;
+ board[movelog[movenum - 1]].s_occ =
+ (movenum & 1) != 0 ? BLACK : WHITE;
movenum++;
bdisp();
goto top;
@@ -436,19 +442,19 @@
d1 = s1 = 0;
n = 0;
- for (str = input + 1; *str; str++)
+ for (str = input + 1; *str != '\0'; str++)
if (*str == ',') {
for (d1 = 0; d1 < 4; d1++)
if (str[-1] == pdir[d1])
break;
str[-1] = '\0';
sp = &board[s1 = ctos(input + 1)];
- n = (sp->s_frame[d1] - frames) * FAREA;
+ n = (int)((sp->s_frame[d1] - frames) * FAREA);
*str++ = '\0';
break;
}
sp = &board[s2 = ctos(str)];
- while (*str)
+ while (*str != '\0')
str++;
for (d2 = 0; d2 < 4; d2++)
if (str[-1] == pdir[d2])
@@ -478,9 +484,9 @@
else
n = 0;
sp = &board[i = ctos(str)];
- for (ep = sp->s_empty; ep; ep = ep->e_next) {
+ for (ep = sp->s_empty; ep != NULL; ep = ep->e_next) {
cbp = ep->e_combo;
- if (n) {
+ if (n != 0) {
if (cbp->c_nframes > n)
continue;
if (cbp->c_nframes != n)
@@ -550,11 +556,13 @@
exit(0);
}
+#if !defined(DEBUG)
static void
quitsig(int dummy __unused)
{
quit();
}
+#endif
/*
* Die gracefully.
diff -r ab7ee610d63b -r 31c02a929e44 games/gomoku/pickmove.c
--- a/games/gomoku/pickmove.c Mon May 16 21:28:05 2022 +0000
+++ b/games/gomoku/pickmove.c Mon May 16 21:35:39 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pickmove.c,v 1.31 2022/05/16 21:02:18 rillig Exp $ */
+/* $NetBSD: pickmove.c,v 1.32 2022/05/16 21:35:39 rillig Exp $ */
/*
* Copyright (c) 1994
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)pickmove.c 8.2 (Berkeley) 5/3/95";
#else
-__RCSID("$NetBSD: pickmove.c,v 1.31 2022/05/16 21:02:18 rillig Exp $");
+__RCSID("$NetBSD: pickmove.c,v 1.32 2022/05/16 21:35:39 rillig Exp $");
#endif
#endif /* not lint */
@@ -398,12 +398,12 @@
combolen = 0;
#ifdef DEBUG
- if (combocnt) {
+ if (combocnt != 0) {
debuglog("scanframes: %c combocnt %d", "BW"[color],
combocnt);
whatsup(0);
}
- if (elistcnt) {
+ if (elistcnt != 0) {
debuglog("scanframes: %c elistcnt %d", "BW"[color],
elistcnt);
whatsup(0);
@@ -687,7 +687,7 @@
#ifdef DEBUG
if (sp->s_occ != EMPTY) {
debuglog("loop: %c %s", "BW"[curcolor],
- stoc(sp - board));
+ stoc((int)(sp - board)));
whatsup(0);
}
#endif
@@ -1349,7 +1349,7 @@
void
markcombo(struct combostr *ocbp)
{
- struct combostr *cbp, *tcbp, **cbpp;
+ struct combostr *cbp, **cbpp;
struct elist *ep, *nep;
struct spotstr *sp;
int s, d, m, i;
@@ -1373,7 +1373,7 @@
*/
ep = &einfo[nframes];
cbpp = &ecombo[nframes];
- for (cbp = ocbp; (tcbp = cbp->c_link[1]) != NULL; cbp = cbp->c_link[0]) {
+ for (cbp = ocbp; cbp->c_link[1] != NULL; cbp = cbp->c_link[0]) {
ep--;
ep->e_combo = cbp;
*--cbpp = cbp->c_link[1];
@@ -1401,14 +1401,14 @@
nep->e_framecnt = cbp->c_framecnt[0];
nep->e_emask = cbp->c_emask[0];
- if (cbp->c_flags & C_LOOP) {
+ if ((cbp->c_flags & C_LOOP) != 0) {
s++;
/*
* Account for the fact that this frame connects
* to a previous one (thus forming a loop).
*/
nep = &einfo[cbp->c_dir];
- if (--nep->e_framecnt)
+ if (--nep->e_framecnt != 0)
nep->e_emask &= ~(1 << cbp->c_voff[0]);
else
nep->e_emask = 0;
@@ -1419,13 +1419,13 @@
* We only need to update the emask values of "complete" loops
* to include the intersection spots.
*/
- if (s && ocbp->c_combo.c.a == 2) {
+ if (s != 0 && ocbp->c_combo.c.a == 2) {
/* process loops from the top down */
ep = &einfo[nframes];
do {
ep--;
cbp = ep->e_combo;
- if (!(cbp->c_flags & C_LOOP))
+ if ((cbp->c_flags & C_LOOP) == 0)
continue;
/*
@@ -1454,9 +1454,10 @@
d = dd[s = cbp->c_dir];
cmask = CFLAG << s;
omask = (IFLAG | CFLAG) << s;
- s = ep->e_fval.c.b ? 6 : 5;
+ s = ep->e_fval.c.b != 0 ? 6 : 5;
+ /* LINTED 117: bitwise '>>' on signed value possibly nonportable */
for (; --s >= 0; sp += d, m >>= 1)
- sp->s_flags |= (m & 1) ? omask : cmask;
+ sp->s_flags |= (m & 1) != 0 ? omask : cmask;
}
}
@@ -1474,7 +1475,7 @@
sp = &board[cbp->c_vertex];
d = dd[n = cbp->c_dir];
mask = ~((IFLAG | CFLAG) << n);
- n = open ? 6 : 5;
+ n = open != 0 ? 6 : 5;
for (; --n >= 0; sp += d)
sp->s_flags &= mask;
}
Home |
Main Index |
Thread Index |
Old Index