From 981710835fb91625593928380d26952642118781 Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Mon, 4 Apr 2016 10:53:26 +0200 Subject: [PATCH] Silence Clang warnings The assignment of the variant number to appData.variant was a real bug. The signedness of EP_STATUS looked like one, but seemed to work in practice. --- backend.c | 33 +++++++++++++++++++++++---------- book.c | 3 ++- gtk/xboard.c | 18 +++++++++--------- gtk/xoptions.c | 1 + moves.c | 6 +++--- parser.c | 2 +- 6 files changed, 39 insertions(+), 24 deletions(-) diff --git a/backend.c b/backend.c index a89311b..0223dfb 100644 --- a/backend.c +++ b/backend.c @@ -3395,7 +3395,8 @@ read_from_ics (InputSourceRef isr, VOIDSTAR closure, char *data, int count, int #if ZIPPY if (loggedOn == TRUE) if (ZippyControl(buf, &backup) || ZippyConverse(buf, &backup) || - (appData.zippyPlay && ZippyMatch(buf, &backup))); + (appData.zippyPlay && ZippyMatch(buf, &backup))) + ; #endif } // [DM] 'else { ' deleted if ( @@ -9278,7 +9279,7 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h if(initPing == cps->lastPong) { if(gameInfo.variant == VariantUnknown) { DisplayError(_("Engine did not send setup for non-standard variant"), 0); - *engineVariant = NULLCHAR; appData.variant = VariantNormal; // back to normal as error recovery? + *engineVariant = NULLCHAR; ASSIGN(appData.variant, "normal"); // back to normal as error recovery? GameEnds(GameUnfinished, NULL, GE_XBOARD); } initPing = -1; @@ -10324,7 +10325,8 @@ ApplyMove (int fromX, int fromY, int toX, int toY, int promoChar, Board board) } else if (board[fromY][fromX] == king && fromX != BOARD_LEFT && fromX != BOARD_RGHT-1 // [HGM] cylinder */ && toY == fromY && toX > fromX+1) { - for(rookX=fromX+1; board[toY][rookX] == EmptySquare && rookX < BOARD_RGHT-1; rookX++); // castle with nearest piece + for(rookX=fromX+1; board[toY][rookX] == EmptySquare && rookX < BOARD_RGHT-1; rookX++) + ; // castle with nearest piece board[fromY][toX-1] = board[fromY][rookX]; board[fromY][rookX] = EmptySquare; board[fromY][fromX] = EmptySquare; @@ -10332,7 +10334,8 @@ ApplyMove (int fromX, int fromY, int toX, int toY, int promoChar, Board board) } else if (board[fromY][fromX] == king && fromX != BOARD_LEFT && fromX != BOARD_RGHT-1 // [HGM] cylinder */ && toY == fromY && toX < fromX-1) { - for(rookX=fromX-1; board[toY][rookX] == EmptySquare && rookX > 0; rookX--); // castle with nearest piece + for(rookX=fromX-1; board[toY][rookX] == EmptySquare && rookX > 0; rookX--) + ; // castle with nearest piece board[fromY][toX+1] = board[fromY][rookX]; board[fromY][rookX] = EmptySquare; board[fromY][fromX] = EmptySquare; @@ -10375,7 +10378,8 @@ ApplyMove (int fromX, int fromY, int toX, int toY, int promoChar, Board board) } else if (board[fromY][fromX] == king && fromX != BOARD_LEFT && fromX != BOARD_RGHT-1 // [HGM] cylinder */ && toY == fromY && toX > fromX+1) { - for(rookX=toX+1; board[toY][rookX] == EmptySquare && rookX < BOARD_RGHT - 1; rookX++); + for(rookX=toX+1; board[toY][rookX] == EmptySquare && rookX < BOARD_RGHT - 1; rookX++) + ; board[fromY][toX-1] = board[fromY][rookX]; board[fromY][rookX] = EmptySquare; board[fromY][fromX] = EmptySquare; @@ -10383,7 +10387,8 @@ ApplyMove (int fromX, int fromY, int toX, int toY, int promoChar, Board board) } else if (board[fromY][fromX] == king && fromX != BOARD_LEFT && fromX != BOARD_RGHT-1 // [HGM] cylinder */ && toY == fromY && toX < fromX-1) { - for(rookX=toX-1; board[toY][rookX] == EmptySquare && rookX > 0; rookX--); + for(rookX=toX-1; board[toY][rookX] == EmptySquare && rookX > 0; rookX--) + ; board[fromY][toX+1] = board[fromY][rookX]; board[fromY][rookX] = EmptySquare; board[fromY][fromX] = EmptySquare; @@ -11078,8 +11083,10 @@ Substitute (char *participants, int expunge) p++; q++; } if(*p) { // difference - while(*p && *p++ != '\n'); - while(*q && *q++ != '\n'); + while(*p && *p++ != '\n') + ; + while(*q && *q++ != '\n') + ; changed = nPlayers; changes = 1 + (strcmp(p, q) != 0); } @@ -16799,7 +16806,11 @@ GetInfoFromComment (int index, char * text) pvInfoList[index-1].score = score; pvInfoList[index-1].time = 10*time; // centi-sec if(*sep == '}') *sep = 0; else *--sep = '{'; - if(p != text) { while(*p++ = *sep++); sep = text; } // squeeze out space between PV and comment, and return both + if(p != text) { + while(*p++ = *sep++) + ; + sep = text; + } // squeeze out space between PV and comment, and return both } return sep; } @@ -18243,7 +18254,9 @@ PositionToFEN (int move, char *overrideCastling, int moveCounts) } if(q = overrideCastling) { // [HGM] FRC: override castling & e.p fields for non-compliant engines - while(*p++ = *q++); if(q != overrideCastling+1) p[-1] = ' '; else --p; + while(*p++ = *q++) + ; + if(q != overrideCastling+1) p[-1] = ' '; else --p; } else { if(haveRights) { int handW=0, handB=0; diff --git a/book.c b/book.c index 1c013c2..9828dd2 100644 --- a/book.c +++ b/book.c @@ -1029,7 +1029,8 @@ PlayBookMove(char *text, int index) { char *start = text+index, *end = start; while(start > text && start[-1] != ' ' && start[-1] != '\t') start--; - while(*end && *++end != ' ' && *end != '\n'); *end = NULLCHAR; // find clicked word + while(*end && *++end != ' ' && *end != '\n') + ; *end = NULLCHAR; // find clicked word if(start != end) TypeInDoneEvent(start); // fake it was typed in move type-in } diff --git a/gtk/xboard.c b/gtk/xboard.c index a7b10ca..8dc5253 100644 --- a/gtk/xboard.c +++ b/gtk/xboard.c @@ -2329,15 +2329,15 @@ UpdateLogos (int displ) return; } -void FileNamePopUpWrapper(label, def, filter, proc, pathFlag, openMode, name, fp) - char *label; - char *def; - char *filter; - FileProc proc; - char *openMode; - Boolean pathFlag; - char **name; - FILE **fp; +void FileNamePopUpWrapper( + char *label, + char *def, + char *filter, + FileProc proc, + Boolean pathFlag, + char *openMode, + char **name, + FILE **fp) { GtkWidget *dialog; GtkFileFilter *gtkfilter; diff --git a/gtk/xoptions.c b/gtk/xoptions.c index d9e528a..6e029aa 100644 --- a/gtk/xoptions.c +++ b/gtk/xoptions.c @@ -1025,6 +1025,7 @@ GraphEventProc(GtkWidget *widget, GdkEvent *event, gpointer gdata) case GDK_SCROLL: if(sevent->direction == GDK_SCROLL_UP) button = 4; if(sevent->direction == GDK_SCROLL_DOWN) button = 5; + w = h = 0; // to keep Clang happy break; case GDK_MOTION_NOTIFY: f = 0; diff --git a/moves.c b/moves.c index abf1936..3205d2f 100644 --- a/moves.c +++ b/moves.c @@ -1408,7 +1408,7 @@ GenLegalCallback (Board board, int flags, ChessMove kind, int rf, int ff, int rt if(rFilter >= 0 && rFilter != rt || fFilter >= 0 && fFilter != ft) return; // [HGM] speed: ignore moves with wrong to-square - if (board[EP_STATUS] == EP_IRON_LION && (board[rt][ft] == WhiteLion || board[rt][ft] == BlackLion)) return; //[HGM] lion + if ((int)board[EP_STATUS] == EP_IRON_LION && (board[rt][ft] == WhiteLion || board[rt][ft] == BlackLion)) return; //[HGM] lion if (!(flags & F_IGNORE_CHECK) ) { int check, promo = (gameInfo.variant == VariantSpartan && kind == BlackPromotion); @@ -1664,11 +1664,11 @@ CheckTestCallback (Board board, int flags, ChessMove kind, int rf, int ff, int r register CheckTestClosure *cl = (CheckTestClosure *) closure; if (rt == cl->rking && ft == cl->fking) { - if(xqCheckers[EP_STATUS] >= 2 && xqCheckers[rf][ff]) return; // checker is piece with suspended checking power + if((int)xqCheckers[EP_STATUS] >= 2 && xqCheckers[rf][ff]) return; // checker is piece with suspended checking power cl->check++; xqCheckers[rf][ff] = xqCheckers[EP_STATUS] & 1; // remember who is checking (if status == 1) } - if( board[EP_STATUS] == EP_ROYAL_LION && (board[rt][ft] == WhiteLion || board[rt][ft] == BlackLion) + if( (int)board[EP_STATUS] == EP_ROYAL_LION && (board[rt][ft] == WhiteLion || board[rt][ft] == BlackLion) && (gameInfo.variant != VariantLion || board[rf][ff] != WhiteKing && board[rf][ff] != BlackKing) ) cl->check++; // [HGM] lion: forbidden counterstrike against Lion equated to putting yourself in check } diff --git a/parser.c b/parser.c index e325005..8378132 100644 --- a/parser.c +++ b/parser.c @@ -585,7 +585,7 @@ NextUnit (char **p) if(killX < 0) // [HGM] lion: do not overwrite kill-square suffix currentMoveString[4] = cl.promoChar; - if((cl.kind == WhiteCapturesEnPassant || cl.kind == BlackCapturesEnPassant) && (Match("ep", p) || Match("e.p.", p))); + if((cl.kind == WhiteCapturesEnPassant || cl.kind == BlackCapturesEnPassant) && !Match("ep", p)) Match("e.p.", p); return (int) cl.kind; } -- 1.7.0.4