Module Name: src Committed By: rillig Date: Mon May 16 21:35:39 UTC 2022
Modified Files: src/games/gomoku: bdisp.c main.c pickmove.c Log Message: gomoku: fix most lint warnings in -DDEBUG mode No binary change. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/games/gomoku/bdisp.c cvs rdiff -u -r1.34 -r1.35 src/games/gomoku/main.c cvs rdiff -u -r1.31 -r1.32 src/games/gomoku/pickmove.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/games/gomoku/bdisp.c diff -u src/games/gomoku/bdisp.c:1.24 src/games/gomoku/bdisp.c:1.25 --- src/games/gomoku/bdisp.c:1.24 Mon May 16 20:57:01 2022 +++ src/games/gomoku/bdisp.c Mon May 16 21:35:39 2022 @@ -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 @@ bdump(FILE *fp) 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 = '.'; Index: src/games/gomoku/main.c diff -u src/games/gomoku/main.c:1.34 src/games/gomoku/main.c:1.35 --- src/games/gomoku/main.c:1.34 Mon May 16 21:02:18 2022 +++ src/games/gomoku/main.c Mon May 16 21:35:39 2022 @@ -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 @@ __COPYRIGHT("@(#) Copyright (c) 1994\ #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 @@ const char *plyr[2]; /* who's who */ 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 @@ readinput(FILE *fp) /* * Handle strange situations. */ +/* ARGSUSED */ void whatsup(int signum) { @@ -390,10 +393,12 @@ top: 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 @@ top: 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 @@ top: 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 @@ top: 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 @@ quit(void) exit(0); } +#if !defined(DEBUG) static void quitsig(int dummy __unused) { quit(); } +#endif /* * Die gracefully. Index: src/games/gomoku/pickmove.c diff -u src/games/gomoku/pickmove.c:1.31 src/games/gomoku/pickmove.c:1.32 --- src/games/gomoku/pickmove.c:1.31 Mon May 16 21:02:18 2022 +++ src/games/gomoku/pickmove.c Mon May 16 21:35:39 2022 @@ -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 @@ scanframes(int color) 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 @@ makecombo(struct combostr *ocbp, struct #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 @@ printcombo(struct combostr *cbp, char *b 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 @@ markcombo(struct combostr *ocbp) */ 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 @@ markcombo(struct combostr *ocbp) 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 @@ markcombo(struct combostr *ocbp) * 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 @@ markcombo(struct combostr *ocbp) 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 @@ clearcombo(struct combostr *cbp, int ope 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; }