Skip to content

Commit 148855d

Browse files
committed
Fixed a few compiler warnings.
1 parent c424d97 commit 148855d

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

src/uistdio.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,7 @@ bool ChessUI_stdio::ReadMove (
433433
printf ( "!!! Ignoring invalid time limit\n" );
434434
}
435435
}
436-
else if ( sscanf ( s, "edit %[a-zA-Z1-8.]", temp ) == 1
437-
&& strlen(temp)==3 )
436+
else if (sscanf(s, "edit %[a-zA-Z1-8.]", temp)==1 && strlen(temp)==3 )
438437
{
439438
int x = temp[1] - 'a';
440439
int y = temp[2] - '1';

src/uiwin32.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,7 @@ void ChessUI_win32_gui::blunderAlert_FormatContinuation(
12111211
int maxTextLength)
12121212
{
12131213
int d = 0; // must init before first usage of SafeAppendToken macro
1214-
memset(text, '\0', 1 + maxTextLength);
1214+
memset(text, '\0', 1 + (size_t)maxTextLength);
12151215
int length = 0;
12161216

12171217
if (!parms || moveIndex < 0 || moveIndex >= parms->numLegalMoves)

src/wbrdbuf.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ BoardDisplayBuffer::BoardDisplayBuffer():
4949
tempHDC(nullptr),
5050
inPromotionPrompt(false),
5151
prom_x(-1),
52-
prom_y(-1)
52+
prom_y(-1),
53+
moverIsWhite(false),
54+
vx1(0),
55+
vx2(0),
56+
vy1(0),
57+
vy2(0)
5358
{
5459
for ( int x=0; x < 8; x++ )
5560
{
@@ -428,13 +433,9 @@ void BoardDisplayBuffer::draw (
428433
loadBitmaps (global_hInstance);
429434

430435
for ( int y=miny; y <= maxy; y++ )
431-
{
432436
for ( int x=minx; x <= maxx; x++ )
433-
{
434-
// Put the bitmap in the presentation space given.
435-
drawSquare ( hdc, board[x][y], x, y );
436-
}
437-
}
437+
if (x >= 0 && x < 8 && y >= 0 && y < 8)
438+
drawSquare ( hdc, board[x][y], x, y );
438439

439440
HBRUSH oldbrush = (HBRUSH) SelectObject ( hdc, GetStockObject(NULL_BRUSH) );
440441
HPEN oldpen = (HPEN) SelectObject ( hdc, GetStockObject(BLACK_PEN) );

src/wingui.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,6 +1233,9 @@ void ReadChenardSetting (const char *key, const char *defaultValue, char *opt, s
12331233
{
12341234
bool readValue = false; // if remains false, it means we failed to read data and will use defaultValue
12351235

1236+
if (opt == nullptr)
1237+
return;
1238+
12361239
HKEY softwareKeyHandle;
12371240
LSTATUS status = RegOpenKeyEx (
12381241
HKEY_CURRENT_USER,
@@ -1274,11 +1277,8 @@ void ReadChenardSetting (const char *key, const char *defaultValue, char *opt, s
12741277
RegCloseKey (softwareKeyHandle);
12751278
}
12761279

1277-
12781280
if (!readValue)
1279-
{
1280-
strcpy_s (opt, optSize, defaultValue);
1281-
}
1281+
strcpy_s(opt, optSize, defaultValue);
12821282
}
12831283

12841284

@@ -1632,11 +1632,11 @@ void SetDirectoryFromFilePath (const char *filepath)
16321632
if (backslash)
16331633
{
16341634
int length = (int) (backslash - filepath);
1635-
char *path = new char [length + 1];
1635+
char *path = new char [(size_t)length + 1];
16361636
memcpy (path, filepath, length);
16371637
path[length] = '\0';
16381638

1639-
_chdir (path);
1639+
(void)_chdir(path);
16401640

16411641
delete[] path;
16421642
}

0 commit comments

Comments
 (0)