Source-Changes-HG archive

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

[src/trunk]: src/games/backgammon/backgammon Add strategic assertion, now pas...



details:   https://anonhg.NetBSD.org/src/rev/e05ea61fe8fa
branches:  trunk
changeset: 782051:e05ea61fe8fa
user:      dholland <dholland%NetBSD.org@localhost>
date:      Sat Oct 13 19:39:57 2012 +0000

description:
Add strategic assertion, now passes -Wstrict-overflow.

diffstat:

 games/backgammon/backgammon/move.c |  12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diffs (33 lines):

diff -r 40cff2326df5 -r e05ea61fe8fa games/backgammon/backgammon/move.c
--- a/games/backgammon/backgammon/move.c        Sat Oct 13 19:38:24 2012 +0000
+++ b/games/backgammon/backgammon/move.c        Sat Oct 13 19:39:57 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: move.c,v 1.12 2012/10/13 19:19:38 dholland Exp $       */
+/*     $NetBSD: move.c,v 1.13 2012/10/13 19:39:57 dholland Exp $       */
 
 /*
  * Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)move.c     8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: move.c,v 1.12 2012/10/13 19:19:38 dholland Exp $");
+__RCSID("$NetBSD: move.c,v 1.13 2012/10/13 19:39:57 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -167,6 +167,14 @@
                writec('-');
                wrint(mm->g[i] = cg[i]);
                makmove(mm, i);
+
+               /*
+                * This assertion persuades gcc 4.5 that the loop
+                * doesn't result in signed overflow of i. mvlim
+                * isn't, or at least shouldn't be, changed by makmove
+                * at all.
+                */
+               assert(mm->mvlim >= 0 && mm->mvlim <= 5);
        }
        writec('.');
 



Home | Main Index | Thread Index | Old Index