Module Name: src Committed By: rillig Date: Mon May 16 21:48:46 UTC 2022
Modified Files: src/games/gomoku: Makefile bdisp.c gomoku.h main.c makemove.c pickmove.c Log Message: gomoku: enable lint's strict bool mode No functional change. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/games/gomoku/Makefile cvs rdiff -u -r1.25 -r1.26 src/games/gomoku/bdisp.c cvs rdiff -u -r1.27 -r1.28 src/games/gomoku/gomoku.h cvs rdiff -u -r1.36 -r1.37 src/games/gomoku/main.c cvs rdiff -u -r1.15 -r1.16 src/games/gomoku/makemove.c cvs rdiff -u -r1.32 -r1.33 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/Makefile diff -u src/games/gomoku/Makefile:1.8 src/games/gomoku/Makefile:1.9 --- src/games/gomoku/Makefile:1.8 Mon May 16 21:02:18 2022 +++ src/games/gomoku/Makefile Mon May 16 21:48:45 2022 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.8 2022/05/16 21:02:18 rillig Exp $ +# $NetBSD: Makefile,v 1.9 2022/05/16 21:48:45 rillig Exp $ # @(#)Makefile 8.1 (Berkeley) 7/24/94 PROG= gomoku @@ -10,6 +10,6 @@ HIDEGAME=hidegame CPPFLAGS+= ${DEBUG:D-DDEBUG} LINTFLAGS+= -w # treat warnings as errors -#LINTFLAGS+= -T # strict bool mode +LINTFLAGS+= -T # strict bool mode .include <bsd.prog.mk> Index: src/games/gomoku/bdisp.c diff -u src/games/gomoku/bdisp.c:1.25 src/games/gomoku/bdisp.c:1.26 --- src/games/gomoku/bdisp.c:1.25 Mon May 16 21:35:39 2022 +++ src/games/gomoku/bdisp.c Mon May 16 21:48:45 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: bdisp.c,v 1.25 2022/05/16 21:35:39 rillig Exp $ */ +/* $NetBSD: bdisp.c,v 1.26 2022/05/16 21:48:45 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.25 2022/05/16 21:35:39 rillig Exp $"); +__RCSID("$NetBSD: bdisp.c,v 1.26 2022/05/16 21:48:45 rillig Exp $"); #endif #endif /* not lint */ @@ -128,7 +128,7 @@ bdisp_init(void) * Update who is playing whom. */ void -bdwho(int update) +bdwho(bool update) { int i, j; @@ -275,7 +275,7 @@ get_key(const char *allowed) return ch; } -int +bool get_line(char *buf, int size) { char *cp, *end; Index: src/games/gomoku/gomoku.h diff -u src/games/gomoku/gomoku.h:1.27 src/games/gomoku/gomoku.h:1.28 --- src/games/gomoku/gomoku.h:1.27 Mon May 16 21:02:18 2022 +++ src/games/gomoku/gomoku.h Mon May 16 21:48:45 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: gomoku.h,v 1.27 2022/05/16 21:02:18 rillig Exp $ */ +/* $NetBSD: gomoku.h,v 1.28 2022/05/16 21:48:45 rillig Exp $ */ /* * Copyright (c) 1994 @@ -230,13 +230,13 @@ extern int movelog[BSZ * BSZ]; /* histo extern int movenum; extern int debug; -extern int interactive; +extern bool interactive; extern const char *plyr[]; void bdinit(struct spotstr *); int get_coord(void); -int get_key(const char *allowedkeys); -int get_line(char *, int); +int get_key(const char *); +bool get_line(char *, int); void ask(const char *); void dislog(const char *); void bdump(FILE *); @@ -244,7 +244,7 @@ void bdisp(void); void bdisp_init(void); void cursfini(void); void cursinit(void); -void bdwho(int); +void bdwho(bool); void panic(const char *, ...) __printflike(1, 2) __dead; void debuglog(const char *, ...) __printflike(1, 2); void whatsup(int); Index: src/games/gomoku/main.c diff -u src/games/gomoku/main.c:1.36 src/games/gomoku/main.c:1.37 --- src/games/gomoku/main.c:1.36 Mon May 16 21:38:46 2022 +++ src/games/gomoku/main.c Mon May 16 21:48:45 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.36 2022/05/16 21:38:46 rillig Exp $ */ +/* $NetBSD: main.c,v 1.37 2022/05/16 21:48:45 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.36 2022/05/16 21:38:46 rillig Exp $"); +__RCSID("$NetBSD: main.c,v 1.37 2022/05/16 21:48:45 rillig Exp $"); #endif #endif /* not lint */ @@ -62,7 +62,7 @@ __RCSID("$NetBSD: main.c,v 1.36 2022/05/ #define PROGRAM 1 /* get input from program */ #define INPUTF 2 /* get input from a file */ -int interactive = true; /* true if interactive */ +bool interactive = true; /* true if interactive */ int debug; /* > 0 if debugging */ static int test; /* both moves come from 1: input, 2: computer */ static char *prog; /* name of program */ Index: src/games/gomoku/makemove.c diff -u src/games/gomoku/makemove.c:1.15 src/games/gomoku/makemove.c:1.16 --- src/games/gomoku/makemove.c:1.15 Mon May 16 20:57:01 2022 +++ src/games/gomoku/makemove.c Mon May 16 21:48:45 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: makemove.c,v 1.15 2022/05/16 20:57:01 rillig Exp $ */ +/* $NetBSD: makemove.c,v 1.16 2022/05/16 21:48:45 rillig Exp $ */ /* * Copyright (c) 1994 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)makemove.c 8.2 (Berkeley) 5/3/95"; #else -__RCSID("$NetBSD: makemove.c,v 1.15 2022/05/16 20:57:01 rillig Exp $"); +__RCSID("$NetBSD: makemove.c,v 1.16 2022/05/16 21:48:45 rillig Exp $"); #endif #endif /* not lint */ @@ -69,7 +69,8 @@ makemove(int us, int mv) struct combostr *cbp, *cbp1; union comboval *cp1; int i, f, r, d, n; - int space, val, bmask; + int val, bmask; + bool space; /* check for end of game */ if (mv == RESIGN) Index: src/games/gomoku/pickmove.c diff -u src/games/gomoku/pickmove.c:1.32 src/games/gomoku/pickmove.c:1.33 --- src/games/gomoku/pickmove.c:1.32 Mon May 16 21:35:39 2022 +++ src/games/gomoku/pickmove.c Mon May 16 21:48:45 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: pickmove.c,v 1.32 2022/05/16 21:35:39 rillig Exp $ */ +/* $NetBSD: pickmove.c,v 1.33 2022/05/16 21:48:45 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.32 2022/05/16 21:35:39 rillig Exp $"); +__RCSID("$NetBSD: pickmove.c,v 1.33 2022/05/16 21:48:45 rillig Exp $"); #endif #endif /* not lint */ @@ -53,7 +53,7 @@ __RCSID("$NetBSD: pickmove.c,v 1.32 2022 #define BIT_SET(a, b) ((a)[(b)/BITS_PER_INT] |= (1 << ((b) % BITS_PER_INT))) #define BIT_CLR(a, b) ((a)[(b)/BITS_PER_INT] &= ~(1 << ((b) % BITS_PER_INT))) -#define BIT_TEST(a, b) (((a)[(b)/BITS_PER_INT] & (1 << ((b) % BITS_PER_INT)))) +#define BIT_TEST(a, b) (((a)[(b)/BITS_PER_INT] & (1 << ((b) % BITS_PER_INT))) != 0) /* * This structure is used to store overlap information between frames. @@ -74,7 +74,7 @@ static int forcemap[MAPSZ]; /* map for static int tmpmap[MAPSZ]; /* map for blocking <1,x> combos */ static int nforce; /* count of opponent <1,x> combos */ -static int better(const struct spotstr *, const struct spotstr *, int); +static bool better(const struct spotstr *, const struct spotstr *, int); static void scanframes(int); static void makecombo2(struct combostr *, struct spotstr *, int, int); static void addframes(int); @@ -192,7 +192,7 @@ pickmove(int us) /* * Return true if spot 'sp' is better than spot 'sp1' for color 'us'. */ -static int +static bool better(const struct spotstr *sp, const struct spotstr *sp1, int us) { int them, s, s1; @@ -207,8 +207,8 @@ better(const struct spotstr *sp, const s them = us != BLACK ? BLACK : WHITE; s = (int)(sp - board); s1 = (int)(sp1 - board); - if ((BIT_TEST(forcemap, s) != 0) != (BIT_TEST(forcemap, s1) != 0)) - return BIT_TEST(forcemap, s) != 0; + if (BIT_TEST(forcemap, s) != BIT_TEST(forcemap, s1)) + return BIT_TEST(forcemap, s); if (/* .... */ sp->s_combo[them].s != sp1->s_combo[them].s) return sp->s_combo[them].s < sp1->s_combo[them].s; @@ -1110,7 +1110,7 @@ checkframes(struct combostr *cbp, struct myindex--; mask = str[tcbp - frames]; flags = cbp->c_flags; - n = i + ((flags & C_OPEN_1) != 0); + n = i + ((flags & C_OPEN_1) != 0 ? 1 : 0); if ((mask & (1 << n)) != 0) { /* * The two frames are not independent if they @@ -1153,7 +1153,7 @@ checkframes(struct combostr *cbp, struct verts++; } } - n = i + ((flags & C_OPEN_0) != 0); + n = i + ((flags & C_OPEN_0) != 0 ? 1 : 0); } if (cbp == fcbp) return -1; /* fcbp is already included */