From: Yann Dirson Date: Thu, 17 Jan 2008 23:19:24 +0000 (+0100) Subject: Fix integer overflow caused by bad use of binary operator. X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=9167c0e40628c12ae7b0f0ff679f285d53d253ae;p=gnushogi.git Fix integer overflow caused by bad use of binary operator. Guess this may make the AI more accurate :) Problem caught by gcc: ../../gnushogi/search.c: In function 'search': ../../gnushogi/search.c:887: warning: overflow in implicit constant conversion A quick audit only revealed a place where another logical AND was tested using a curious idiom, so let's make it consistent at the same time. --- diff --git a/gnushogi/eval.c b/gnushogi/eval.c index 3f44d9b..d2dcfab 100644 --- a/gnushogi/eval.c +++ b/gnushogi/eval.c @@ -1002,7 +1002,7 @@ BRLscan(short sq, short *mob) { \ if (color[u] != c2) \ { \ - if ((atk1[u] == 0) || ((atk2[u] & CNT_MASK) > 1)) \ + if ((atk1[u] == 0) || ((atk2[u] & CNT_MASK) != 0)) \ { \ ++cnt; \ } \ diff --git a/gnushogi/search.c b/gnushogi/search.c index 5be8209..e21ce0e 100644 --- a/gnushogi/search.c +++ b/gnushogi/search.c @@ -881,7 +881,7 @@ search(short side, MakeMove(side, node, &tempb, &tempc, &tempsf, &tempst, &INCscore); - CptrFlag[ply] = (node->flags & capture); + CptrFlag[ply] = ((node->flags & capture) != 0); TesujiFlag[ply] = (node->flags & tesuji) && (node->flags & dropmask); Tscore[ply] = node->score;