Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/games/gomoku gomoku: enable lint's strict bool mode
details: https://anonhg.NetBSD.org/src/rev/c23908f2c522
branches: trunk
changeset: 366167:c23908f2c522
user: rillig <rillig%NetBSD.org@localhost>
date: Mon May 16 21:48:45 2022 +0000
description:
gomoku: enable lint's strict bool mode
No functional change.
diffstat:
games/gomoku/Makefile | 4 ++--
games/gomoku/bdisp.c | 8 ++++----
games/gomoku/gomoku.h | 10 +++++-----
games/gomoku/main.c | 6 +++---
games/gomoku/makemove.c | 7 ++++---
games/gomoku/pickmove.c | 18 +++++++++---------
6 files changed, 27 insertions(+), 26 deletions(-)
diffs (217 lines):
diff -r d40a27df909e -r c23908f2c522 games/gomoku/Makefile
--- a/games/gomoku/Makefile Mon May 16 21:38:46 2022 +0000
+++ b/games/gomoku/Makefile Mon May 16 21:48:45 2022 +0000
@@ -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 @@
CPPFLAGS+= ${DEBUG:D-DDEBUG}
LINTFLAGS+= -w # treat warnings as errors
-#LINTFLAGS+= -T # strict bool mode
+LINTFLAGS+= -T # strict bool mode
.include <bsd.prog.mk>
diff -r d40a27df909e -r c23908f2c522 games/gomoku/bdisp.c
--- a/games/gomoku/bdisp.c Mon May 16 21:38:46 2022 +0000
+++ b/games/gomoku/bdisp.c Mon May 16 21:48:45 2022 +0000
@@ -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 @@
* Update who is playing whom.
*/
void
-bdwho(int update)
+bdwho(bool update)
{
int i, j;
@@ -275,7 +275,7 @@
return ch;
}
-int
+bool
get_line(char *buf, int size)
{
char *cp, *end;
diff -r d40a27df909e -r c23908f2c522 games/gomoku/gomoku.h
--- a/games/gomoku/gomoku.h Mon May 16 21:38:46 2022 +0000
+++ b/games/gomoku/gomoku.h Mon May 16 21:48:45 2022 +0000
@@ -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 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_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);
diff -r d40a27df909e -r c23908f2c522 games/gomoku/main.c
--- a/games/gomoku/main.c Mon May 16 21:38:46 2022 +0000
+++ b/games/gomoku/main.c Mon May 16 21:48:45 2022 +0000
@@ -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 @@
#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 @@
#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 */
diff -r d40a27df909e -r c23908f2c522 games/gomoku/makemove.c
--- a/games/gomoku/makemove.c Mon May 16 21:38:46 2022 +0000
+++ b/games/gomoku/makemove.c Mon May 16 21:48:45 2022 +0000
@@ -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 @@
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)
diff -r d40a27df909e -r c23908f2c522 games/gomoku/pickmove.c
--- a/games/gomoku/pickmove.c Mon May 16 21:38:46 2022 +0000
+++ b/games/gomoku/pickmove.c Mon May 16 21:48:45 2022 +0000
@@ -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 @@
#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 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 @@
/*
* 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 @@
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 @@
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 @@
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 */
Home |
Main Index |
Thread Index |
Old Index