Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/games/gomoku Pass -Wstrict-overflow... mostly.



details:   https://anonhg.NetBSD.org/src/rev/d7f18b72f871
branches:  trunk
changeset: 782058:d7f18b72f871
user:      dholland <dholland%NetBSD.org@localhost>
date:      Sat Oct 13 20:57:35 2012 +0000

description:
Pass -Wstrict-overflow... mostly.

diffstat:

 games/gomoku/bdinit.c   |   8 +++++---
 games/gomoku/pickmove.c |  21 +++++++++++++++------
 2 files changed, 20 insertions(+), 9 deletions(-)

diffs (118 lines):

diff -r cf170fb8f49f -r d7f18b72f871 games/gomoku/bdinit.c
--- a/games/gomoku/bdinit.c     Sat Oct 13 20:42:56 2012 +0000
+++ b/games/gomoku/bdinit.c     Sat Oct 13 20:57:35 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bdinit.c,v 1.8 2009/08/12 06:19:17 dholland Exp $      */
+/*     $NetBSD: bdinit.c,v 1.9 2012/10/13 20:57:35 dholland Exp $      */
 
 /*
  * Copyright (c) 1994
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "from: @(#)bdinit.c     8.2 (Berkeley) 5/3/95";
 #else
-__RCSID("$NetBSD: bdinit.c,v 1.8 2009/08/12 06:19:17 dholland Exp $");
+__RCSID("$NetBSD: bdinit.c,v 1.9 2012/10/13 20:57:35 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -177,6 +177,7 @@
 {
        struct spotstr *sp1, *sp2;
        struct combostr *cbp;
+       unsigned frameix;
        int i, f, r, n, d1, d2;
        int mask, bmask, vertex, s;
        u_char *str;
@@ -186,7 +187,8 @@
        memset(intersect, 0, sizeof(intersect));
        str = &overlap[FAREA * FAREA];
        ip = &intersect[FAREA * FAREA];
-       for (cbp = frames + FAREA; --cbp >= frames; ) {         /* each frame */
+       for (frameix = FAREA; frameix-- > 0; ) {        /* each frame */
+           cbp = &frames[frameix];
            str -= FAREA;
            ip -= FAREA;
            sp1 = &board[vertex = cbp->c_vertex];
diff -r cf170fb8f49f -r d7f18b72f871 games/gomoku/pickmove.c
--- a/games/gomoku/pickmove.c   Sat Oct 13 20:42:56 2012 +0000
+++ b/games/gomoku/pickmove.c   Sat Oct 13 20:57:35 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pickmove.c,v 1.20 2010/03/29 05:16:08 dholland Exp $   */
+/*     $NetBSD: pickmove.c,v 1.21 2012/10/13 20:57:35 dholland 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.20 2010/03/29 05:16:08 dholland Exp $");
+__RCSID("$NetBSD: pickmove.c,v 1.21 2012/10/13 20:57:35 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -83,6 +83,7 @@
 {
        struct spotstr *sp, *sp1, *sp2;
        union comboval *Ocp, *Tcp;
+       unsigned pos;
        int m;
 
        /* first move is easy */
@@ -90,7 +91,8 @@
                return (PT(K,10));
 
        /* initialize all the board values */
-       for (sp = &board[PT(T,20)]; --sp >= &board[PT(A,1)]; ) {
+       for (pos = PT(T,20); pos-- > PT(A,1); ) {
+               sp = &board[pos];
                sp->s_combo[BLACK].s = MAXCOMBO + 1;
                sp->s_combo[WHITE].s = MAXCOMBO + 1;
                sp->s_level[BLACK] = 255;
@@ -108,7 +110,10 @@
        scanframes(WHITE);
 
        /* find the spot with the highest value */
-       for (sp = sp1 = sp2 = &board[PT(T,19)]; --sp >= &board[PT(A,1)]; ) {
+       pos = PT(T,19);
+       sp1 = sp2 = &board[pos];
+       for ( ; pos-- > PT(A,1); ) {
+               sp = &board[pos];
                if (sp->s_occ != EMPTY)
                        continue;
                if (debug && (sp->s_combo[BLACK].c.a == 1 ||
@@ -237,6 +242,7 @@
        struct elist *ep, *nep;
        int i, r, d, n;
        union comboval cb;
+       unsigned pos;
 
        curcolor = color;
 
@@ -345,7 +351,8 @@
        }
 
        /* scan for combos at empty spots */
-       for (sp = &board[PT(T,20)]; --sp >= &board[PT(A,1)]; ) {
+       for (pos = PT(T,20); pos-- > PT(A,1); ) {
+               sp = &board[pos];
                for (ep = sp->s_empty; ep; ep = nep) {
                        cbp = ep->e_combo;
                        if (cbp->c_combo.s <= sp->s_combo[color].s) {
@@ -548,12 +555,14 @@
        int i, r, d;
        struct combostr **cbpp, *pcbp;
        union comboval fcb, cb;
+       unsigned pos;
 
        curlevel = level;
 
        /* scan for combos at empty spots */
        i = curcolor;
-       for (sp = &board[PT(T,20)]; --sp >= &board[PT(A,1)]; ) {
+       for (pos = PT(T,20); pos-- > PT(A,1); ) {
+               sp = &board[pos];
                for (ep = sp->s_empty; ep; ep = nep) {
                        cbp = ep->e_combo;
                        if (cbp->c_combo.s <= sp->s_combo[i].s) {



Home | Main Index | Thread Index | Old Index