From 9167c0e40628c12ae7b0f0ff679f285d53d253ae Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Fri, 18 Jan 2008 00:19:24 +0100 Subject: [PATCH] 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. --- gnushogi/eval.c | 2 +- gnushogi/search.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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; -- 1.7.0.4