From 916e9d3b3acd6422ad21f8edbbe5da768737f2b8 Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Thu, 7 Nov 2013 00:06:47 +0100 Subject: [PATCH] Deal with simple compiler warnings: dead code, unused parameters, etc. --- gnushogi/book.c | 16 +++++-------- gnushogi/commondsp.c | 8 ++++-- gnushogi/cursesdsp.c | 14 ++--------- gnushogi/eval.c | 58 +++++++++++++++++++++++++------------------------- gnushogi/genmove.c | 22 +++++++++--------- gnushogi/gnushogi.h | 5 +--- gnushogi/main.c | 2 +- gnushogi/rawdsp.c | 8 +++--- gnushogi/search.c | 16 +++++++------- gnushogi/util.c | 7 ++--- 10 files changed, 71 insertions(+), 85 deletions(-) diff --git a/gnushogi/book.c b/gnushogi/book.c index 727ae55..88d21be 100644 --- a/gnushogi/book.c +++ b/gnushogi/book.c @@ -365,7 +365,7 @@ RESET(void) static int -Vparse (FILE * fd, USHORT *mv, USHORT *flags, USHORT side, int moveno) +Vparse (FILE * fd, USHORT *mv, USHORT *flags, int moveno) { int c, i; char s[255]; @@ -646,7 +646,7 @@ GetOpenings(void) { short i; int mustwrite = false, first; - unsigned short xside, side; + unsigned short side; short c; USHORT mv, flags; unsigned int x; @@ -715,11 +715,10 @@ GetOpenings(void) { /* setvbuf(fd, buffr, _IOFBF, 2048); */ side = black; - xside = white; hashbd = hashkey = 0; i = 0; - while ((c = Vparse(fd, &mv, &flags, side, i)) >= 0) + while ((c = Vparse(fd, &mv, &flags, i)) >= 0) { if (c == 1) { @@ -821,7 +820,6 @@ GetOpenings(void) computer = opponent; opponent = computer ^ 1; - xside = side; side = side ^ 1; } else if (i > 0) @@ -832,8 +830,6 @@ GetOpenings(void) RESET(); i = 0; side = black; - xside = white; - } } @@ -875,7 +871,7 @@ GetOpenings(void) } - sprintf(msg, "Book used %d(%d).", B.bookcount, B.booksize); + sprintf(msg, "Book used %lu(%lu).", B.bookcount, B.booksize); dsp->ShowMessage(msg); } @@ -894,7 +890,7 @@ GetOpenings(void) /* - * OpeningBook(hint, side) + * OpeningBook(hint) * * Go through each of the opening lines of play and check for a match with * the current game listing. If a match occurs, generate a random @@ -906,7 +902,7 @@ GetOpenings(void) */ int -OpeningBook(unsigned short *hint, short side) +OpeningBook(unsigned short *hint) { unsigned short r, m; int possibles = TrPnt[2] - TrPnt[1]; diff --git a/gnushogi/commondsp.c b/gnushogi/commondsp.c index 36a5f8d..40bfd22 100644 --- a/gnushogi/commondsp.c +++ b/gnushogi/commondsp.c @@ -350,7 +350,7 @@ VerifyMove(char *s, VerifyMove_mode iop, unsigned short *mv) static int -parser(char *f, int side, short *fpiece) +parser(char *f, short *fpiece) { int c1, r1, c2, r2; short i, p = false; @@ -588,7 +588,7 @@ GetGame(void) InPtr = fname; skipb(); g = &GameList[GameCnt]; - g->gmove = parser(InPtr, side, &g->fpiece); + g->gmove = parser(InPtr, &g->fpiece); skip(); g->score = atoi(InPtr); skip(); @@ -1419,7 +1419,7 @@ TestSpeed(void(*f)(short side, short ply, void TestPSpeed(short(*f) (short side), unsigned j) { - short i; + unsigned i; long cnt, t1, t2; #ifdef HAVE_GETTIMEOFDAY struct timeval tv; @@ -1466,6 +1466,7 @@ SetOppTime(char *s) if (*time == ':') { time++; + /* FIXME: sec is parsed but ignored */ sec = (int)strtol(time, &time, 10); } @@ -1500,6 +1501,7 @@ SetMachineTime(char *s) if (*time == ':') { time++; + /* FIXME: sec is parsed but ignored */ sec = (int)strtol(time, &time, 10); } diff --git a/gnushogi/cursesdsp.c b/gnushogi/cursesdsp.c index a42bb26..0914449 100644 --- a/gnushogi/cursesdsp.c +++ b/gnushogi/cursesdsp.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -79,6 +80,7 @@ static void DrawPiece(short sq); static void ShowScore(short score); void Curses_UpdateDisplay(short f, short t, short redraw, short isspec); void Curses_Die(int sig); +void Curses_ShowSidetoMove(void); /**************************************** * Trivial output functions. @@ -107,14 +109,6 @@ gotoXY(short x, short y) } -static void -ClearMessage(void) -{ - gotoXY(TAB, 6); - ClearEoln(); -} - - void Curses_ShowCurrentMove(short pnt, short f, short t) { @@ -773,10 +767,8 @@ DrawPiece(short sq) void Curses_ShowPostnValue(short sq) { - short score; - gotoXY(4 + 5 * VIR_C(sq), 5 + 2 * (7 - VIR_R(sq))); /* CHECKME */ - score = ScorePosition(color[sq]); + (void) ScorePosition(color[sq]); if (color[sq] != neutral) #if defined SAVE_SVALUE diff --git a/gnushogi/eval.c b/gnushogi/eval.c index ac3404a..6457e24 100644 --- a/gnushogi/eval.c +++ b/gnushogi/eval.c @@ -1259,13 +1259,12 @@ trapped(short sq) static int -AttackedPieceValue(short sq, short side) +AttackedPieceValue(short sq) { - short s, ds; + short s; s = 0; - ds = -fv1[HUNGP] * 2; hung[c1]++; shung[sq]++; @@ -1423,7 +1422,7 @@ PawnValue(short sq, short side) */ static inline int -LanceValue(short sq, short side) +LanceValue(short sq) { short s = 0, ds, ad; @@ -1453,7 +1452,7 @@ LanceValue(short sq, short side) */ static inline int -KnightValue(short sq, short side) +KnightValue(short sq) { short s = 0, ad; short ds, checked_trapped = false; @@ -1490,7 +1489,7 @@ KnightValue(short sq, short side) */ static inline int -SilverValue(short sq, short side) +SilverValue(short sq) { short s= 0, ds, ad; @@ -1538,7 +1537,7 @@ SilverValue(short sq, short side) */ static inline int -GoldValue(short sq, short side) +GoldValue(short sq) { short s = 0, ds, ad; @@ -1580,7 +1579,7 @@ GoldValue(short sq, short side) */ static inline int -BishopValue(short sq, short side) +BishopValue(short sq) { short s = 0, ds, ad; @@ -1715,7 +1714,7 @@ RookValue(short sq, short side) */ static inline int -PPawnValue(short sq, short side) +PPawnValue(short sq) { short s = 0, ds, ad; @@ -1732,7 +1731,7 @@ PPawnValue(short sq, short side) */ static inline int -PLanceValue(short sq, short side) +PLanceValue(short sq) { short s = 0, ds, ad; @@ -1748,7 +1747,7 @@ PLanceValue(short sq, short side) */ static inline int -PKnightValue(short sq, short side) +PKnightValue(short sq) { short s = 0, ds, ad; @@ -1765,7 +1764,7 @@ PKnightValue(short sq, short side) */ static inline int -PSilverValue(short sq, short side) +PSilverValue(short sq) { short s = 0, ds, ad; @@ -1781,7 +1780,7 @@ PSilverValue(short sq, short side) */ static inline int -PBishopValue(short sq, short side) +PBishopValue(short sq) { short s = 0, ds, ad; @@ -1797,7 +1796,7 @@ PBishopValue(short sq, short side) */ static inline int -PRookValue(short sq, short side) +PRookValue(short sq) { short s = 0, ds, ad; @@ -1815,7 +1814,7 @@ PRookValue(short sq, short side) */ static inline int -KingValue(short sq, short side) +KingValue(short sq) { short s = 0, ds; @@ -1901,7 +1900,7 @@ PieceValue(short sq, short side) if (a1 == 0) { /* undefended piece */ - s += AttackedPieceValue(sq, side); + s += AttackedPieceValue(sq); } else { @@ -1912,7 +1911,7 @@ PieceValue(short sq, short side) if (attack_value < piece_value) { /* attacked by a weaker piece */ - s += AttackedPieceValue(sq, side) / 2; + s += AttackedPieceValue(sq) / 2; } else if (abs(attack_value - piece_value) < 10) { @@ -1979,24 +1978,24 @@ PieceValue(short sq, short side) #ifndef MINISHOGI case lance: - s += LanceValue(sq, side); + s += LanceValue(sq); break; case knight: - s += KnightValue(sq, side); + s += KnightValue(sq); break; #endif case silver: - s += SilverValue(sq, side); + s += SilverValue(sq); break; case gold: - s += GoldValue(sq, side); + s += GoldValue(sq); break; case bishop: - s += BishopValue(sq, side); + s += BishopValue(sq); break; case rook: @@ -2004,33 +2003,33 @@ PieceValue(short sq, short side) break; case king: - s += KingValue(sq, side); + s += KingValue(sq); break; case ppawn: - s += PPawnValue(sq, side); + s += PPawnValue(sq); break; #ifndef MINISHOGI case plance: - s += PLanceValue(sq, side); + s += PLanceValue(sq); break; case pknight: - s += PKnightValue(sq, side); + s += PKnightValue(sq); break; #endif case psilver: - s += PSilverValue(sq, side); + s += PSilverValue(sq); break; case pbishop: - s += PBishopValue(sq, side); + s += PBishopValue(sq); break; case prook: - s += PRookValue(sq, side); + s += PRookValue(sq); break; } @@ -2741,6 +2740,7 @@ DetermineStage(short side) void UpdateWeights(short stage) { + /* FIXME: this was emptied between 1.1p02 ans 1.2p03, do we keep it ? */ } diff --git a/gnushogi/genmove.c b/gnushogi/genmove.c index 988d0fa..d42c1d6 100644 --- a/gnushogi/genmove.c +++ b/gnushogi/genmove.c @@ -245,7 +245,7 @@ gives_check_flag(unsigned short *flags, short side, short f, short t) inline static void -Link(short side, short piece, +Link(short side, short from, short to, unsigned short local_flag, short s) { if (*TrP == TREE) @@ -340,8 +340,8 @@ PromotionPossible(short color, short f, short t, short p) } -inline int -NonPromotionPossible(short color, short f, +static inline int +NonPromotionPossible(short color, short t, short p) { switch (p) @@ -400,7 +400,7 @@ NonPromotionPossible(short color, short f, /* bonus for possible next moves */ inline static short -field_bonus(short ply, short side, short piece, +field_bonus(short side, short piece, short f, short t, unsigned short *local_flag) { short s, u, ptyp; @@ -620,7 +620,7 @@ LinkMove(short ply, short f, if (score_if_impossible < 0) { /* The move is flagged as illegal. */ - Link(side, piece, + Link(side, f, t, local_flag, score_if_impossible); return; @@ -729,7 +729,7 @@ LinkMove(short ply, short f, s -= 16 / Captured[side][silver]; #if defined DROPBONUS - s += field_bonus(ply, side, piece, f, t, &local_flag); + s += field_bonus(side, piece, f, t, &local_flag); if (s == 10 && piece != pawn) local_flag |= questionable; @@ -818,7 +818,7 @@ LinkMove(short ply, short f, else { #if defined FIELDBONUS - s += field_bonus(ply, side, piece, f, t, &local_flag); + s += field_bonus(side, piece, f, t, &local_flag); #endif } } @@ -870,7 +870,7 @@ LinkMove(short ply, short f, if (try_link || GenerateAllMoves) { - Link(side, piece, f, t, local_flag, + Link(side, f, t, local_flag, s - ((SCORE_LIMIT + 1000) * 2)); } @@ -1040,7 +1040,7 @@ GenMoves(short ply, short sq, short side, LinkMove(ply, sq, u, local_flag | promote, xside, true); if ((possible - = NonPromotionPossible(color[sq], sq, u, piece))) + = NonPromotionPossible(color[sq], u, piece))) { LinkMove(ply, sq, u, local_flag, xside, possible); } @@ -1496,7 +1496,7 @@ CaptureList(short side, short ply, if ((PP = PromotionPossible(color[sq], sq, u, piece))) { - Link(side, piece, + Link(side, sq, u, capture | promote, (*value)[stage][board[u]] #if !defined SAVE_SVALUE @@ -1507,7 +1507,7 @@ CaptureList(short side, short ply, if (!PP || flag.tsume) { - Link(side, piece, + Link(side, sq, u, capture, (*value)[stage][board[u]] #if !defined SAVE_SVALUE diff --git a/gnushogi/gnushogi.h b/gnushogi/gnushogi.h index e1a5471..bbefe5f 100644 --- a/gnushogi/gnushogi.h +++ b/gnushogi/gnushogi.h @@ -916,10 +916,8 @@ extern void Unlock_data(void); /* init.c */ extern void Initialize_dist(void); /* init.c */ extern void Initialize_eval(void); /* eval.c */ extern void NewGame(void); -extern int parse(FILE * fd, unsigned short *mv, - short side, char *opening); extern void GetOpenings(void); -extern int OpeningBook(unsigned short *hint, short side); +extern int OpeningBook(unsigned short *hint); typedef enum { @@ -966,7 +964,6 @@ PutInTTable(short side, short score, short depth, short ply, - short alpha, short beta, unsigned short mv); diff --git a/gnushogi/main.c b/gnushogi/main.c index bcc3338..980d962 100644 --- a/gnushogi/main.c +++ b/gnushogi/main.c @@ -253,7 +253,7 @@ main (int argc, char **argv) } } - printf("The file contains %d entries out of max %d\n", nr[0], i); + printf("The file contains %d entries out of max %ld\n", nr[0], i); for (j = 1; j < MAXDEPTH; j++) printf("%d ", nr[j]); diff --git a/gnushogi/rawdsp.c b/gnushogi/rawdsp.c index 99a9ba0..fa121b0 100644 --- a/gnushogi/rawdsp.c +++ b/gnushogi/rawdsp.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -322,7 +323,7 @@ Raw_help(void) "--------------------------------\n"); printf("Computer: %-12s Opponent: %s\n", ColorStr[computer], ColorStr[opponent]); - printf("Depth: %-12d Response time: %d sec\n", + printf("Depth: %-12d Response time: %ld sec\n", MaxSearchDepth, MaxResponseTime/100); printf("Random: %-12s Easy mode: %s\n", (dither) ? "ON" : "OFF", (flag.easy) ? "ON" : "OFF"); @@ -330,7 +331,7 @@ Raw_help(void) (flag.beep) ? "ON" : "OFF", (flag.hash) ? "ON" : "OFF"); printf("Tsume: %-12s Force: %s\n", (flag.tsume) ? "ON" : "OFF", (flag.force) ? "ON" : "OFF"); - printf("Time Control %s %d moves %d sec %d add %d depth\n", + printf("Time Control %s %d moves %ld sec %d add %d depth\n", (TCflag) ? "ON" : "OFF", TimeControl.moves[black], TimeControl.clock[black] / 100, TCadd/100, MaxSearchDepth); @@ -818,8 +819,7 @@ Raw_ChangeXwindow(void) void Raw_ShowPostnValue(short sq) { - short score; - score = ScorePosition(color[sq]); + (void) ScorePosition(color[sq]); if (color[sq] != neutral) { diff --git a/gnushogi/search.c b/gnushogi/search.c index b8fa819..e87e1d4 100644 --- a/gnushogi/search.c +++ b/gnushogi/search.c @@ -258,7 +258,7 @@ SelectMove(short side, SelectMove_mode iop) if (flag.regularstart && Book) { - flag.timeout = bookflag = OpeningBook(&hint, side); + flag.timeout = bookflag = OpeningBook(&hint); if (TCflag) ResponseTime += ResponseTime; @@ -710,7 +710,7 @@ search(short side, && (ProbeFTable(side, depth, ply, &alpha, &beta, &score) == true)) { - PutInTTable(side, score, depth, ply, alpha, beta, PV); + PutInTTable(side, score, depth, ply, beta, PV); bstline[ply] = PV; bstline[ply + 1] = 0; @@ -1025,13 +1025,13 @@ search(short side, { # ifdef HASHFILE /* MCV: warning: this confuses the formatter. */ if (use_ttable - && PutInTTable(side, best, depth, ply, alpha, beta, mv) + && PutInTTable(side, best, depth, ply, beta, mv) && hashfile && (depth > HashDepth) && (GameCnt < HashMoveLimit)) # else if (use_ttable - && PutInTTable(side, best, depth, ply, alpha, beta, mv)) + && PutInTTable(side, best, depth, ply, beta, mv)) # endif { PutInFTable(side, best, depth, ply, @@ -1116,8 +1116,8 @@ UpdatePieceList(short side, short sq, UpdatePieceList_mode iop) /* Make or Unmake drop move. */ -void -drop(short side, short piece, short f, short t, short iop) +static void +drop(short side, short piece, short t, short iop) { if (iop == 1) { @@ -1285,7 +1285,7 @@ MakeMove(short side, *tempst = svalue[t]; #endif - (void)drop(side, g->fpiece, f, t, 1); + (void)drop(side, g->fpiece, t, 1); } else { @@ -1413,7 +1413,7 @@ UnmakeMove(short side, if (node->flags & dropmask) { - (void)drop(side, (node->flags & pmask), f, t, 2); + (void)drop(side, (node->flags & pmask), t, 2); #if !defined SAVE_SVALUE svalue[t] = *tempst; diff --git a/gnushogi/util.c b/gnushogi/util.c index af57cae..3968ecf 100644 --- a/gnushogi/util.c +++ b/gnushogi/util.c @@ -35,9 +35,9 @@ unsigned int TTadd = 0; short recycle; short ISZERO = 1; - +#if 0 int -parse(FILE * fd, unsigned short *mv, short side, char *opening) +parse(FILE * fd, unsigned short *mv, char *opening) { int c, i, r1, r2, c1, c2; char s[128]; @@ -99,7 +99,7 @@ parse(FILE * fd, unsigned short *mv, short side, char *opening) return 1; } - +#endif /* * The field of a hashtable is computed as follows: @@ -226,7 +226,6 @@ PutInTTable(short side, short score, short depth, short ply, - short alpha, short beta, unsigned short mv) { -- 1.7.0.4