Skip to content

Commit 6cdd733

Browse files
committed
fixed warnings for the latest GCC
1 parent 9ea382a commit 6cdd733

8 files changed

Lines changed: 35 additions & 34 deletions

File tree

game/health.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017-2019 Michael Chaban. All rights reserved.
2+
* Copyright (c) 2017-2020 Michael Chaban. All rights reserved.
33
* Original game is written by Core Design Ltd. in 1997.
44
* Lara Croft and Tomb Raider are trademarks of Square Enix Ltd.
55
*
@@ -54,7 +54,7 @@ void __cdecl DrawAssaultTimer() {
5454
int xPos, yPos, d0, d1, d2;
5555
int minutes, seconds, deciseconds;
5656
DWORD scaleH, scaleV;
57-
char timeString[8];
57+
char timeString[16]; // NOTE: the original buffer was 8
5858

5959
// Exit if current level is not Assault or the timer is hidden
6060
if( CurrentLevel != 0 || !IsAssaultTimerDisplay )

game/invfunc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017-2019 Michael Chaban. All rights reserved.
2+
* Copyright (c) 2017-2020 Michael Chaban. All rights reserved.
33
* Original game is written by Core Design Ltd. in 1997.
44
* Lara Croft and Tomb Raider are trademarks of Square Enix Ltd.
55
*
@@ -252,7 +252,7 @@ void __cdecl RingNotActive(INVENTORY_ITEM *item) {
252252
case ID_LARGE_MEDIPACK_OPTION:
253253
HealthBarTimer = 40; // 1.33 seconds
254254
DrawHealthBar(FlashIt());
255-
// fallthrough here
255+
// fall through
256256
case ID_PUZZLE_OPTION1:
257257
case ID_PUZZLE_OPTION2:
258258
case ID_PUZZLE_OPTION3:

game/laramisc.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -573,14 +573,14 @@ void __cdecl InitialiseLaraInventory(int levelID) {
573573

574574
// NOTE: additional start gun type availability checks not presented in the original game
575575
switch( start->gunType ) {
576-
// if the current weapon is absent then fallthrough
577-
case LGT_Pistols : if( start->has_pistols ) break;
578-
case LGT_Magnums : if( start->has_magnums ) break;
579-
case LGT_Uzis : if( start->has_uzis ) break;
580-
case LGT_Shotgun : if( start->has_shotgun ) break;
581-
case LGT_M16 : if( start->has_m16 ) break;
582-
case LGT_Grenade : if( start->has_grenade ) break;
583-
case LGT_Harpoon : if( start->has_harpoon ) break;
576+
// if the current weapon is absent then fall through
577+
case LGT_Pistols : if( start->has_pistols ) break; // fall through
578+
case LGT_Magnums : if( start->has_magnums ) break; // fall through
579+
case LGT_Uzis : if( start->has_uzis ) break; // fall through
580+
case LGT_Shotgun : if( start->has_shotgun ) break; // fall through
581+
case LGT_M16 : if( start->has_m16 ) break; // fall through
582+
case LGT_Grenade : if( start->has_grenade ) break; // fall through
583+
case LGT_Harpoon : if( start->has_harpoon ) break; // fall through
584584
start->gunType = start->has_pistols ? LGT_Pistols : LGT_Unarmed;
585585
break;
586586
default :

json-parser/json.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ static int new_value (json_state * state,
158158
return 0;
159159
}
160160

161-
value->_reserved.object_mem = (*(char **) &value->u.object.values) + values_size;
161+
value->_reserved.object_mem = (*(void **) &value->u.object.values) + values_size;
162162

163163
value->u.object.length = 0;
164164
break;
@@ -220,7 +220,7 @@ static const long
220220
flag_next = 1 << 0,
221221
flag_reproc = 1 << 1,
222222
flag_need_comma = 1 << 2,
223-
flag_seek_value = 1 << 3,
223+
flag_seek_value = 1 << 3,
224224
flag_escaped = 1 << 4,
225225
flag_string = 1 << 5,
226226
flag_need_colon = 1 << 6,
@@ -289,7 +289,7 @@ json_value * json_parse_ex (json_settings * settings,
289289
for (state.ptr = json ;; ++ state.ptr)
290290
{
291291
json_char b = (state.ptr == end ? 0 : *state.ptr);
292-
292+
293293
if (flags & flag_string)
294294
{
295295
if (!b)
@@ -313,7 +313,7 @@ json_value * json_parse_ex (json_settings * settings,
313313
case 't': string_add ('\t'); break;
314314
case 'u':
315315

316-
if (end - state.ptr <= 4 ||
316+
if (end - state.ptr <= 4 ||
317317
(uc_b1 = hex_value (*++ state.ptr)) == 0xFF ||
318318
(uc_b2 = hex_value (*++ state.ptr)) == 0xFF ||
319319
(uc_b3 = hex_value (*++ state.ptr)) == 0xFF ||
@@ -329,7 +329,7 @@ json_value * json_parse_ex (json_settings * settings,
329329

330330
if ((uchar & 0xF800) == 0xD800) {
331331
json_uchar uchar2;
332-
332+
333333
if (end - state.ptr <= 6 || (*++ state.ptr) != '\\' || (*++ state.ptr) != 'u' ||
334334
(uc_b1 = hex_value (*++ state.ptr)) == 0xFF ||
335335
(uc_b2 = hex_value (*++ state.ptr)) == 0xFF ||
@@ -343,7 +343,7 @@ json_value * json_parse_ex (json_settings * settings,
343343
uc_b1 = (uc_b1 << 4) | uc_b2;
344344
uc_b2 = (uc_b3 << 4) | uc_b4;
345345
uchar2 = (uc_b1 << 8) | uc_b2;
346-
346+
347347
uchar = 0x010000 | ((uchar & 0x3FF) << 10) | (uchar2 & 0x3FF);
348348
}
349349

@@ -373,7 +373,7 @@ json_value * json_parse_ex (json_settings * settings,
373373
string [string_length ++] = 0x80 | ((uchar >> 6) & 0x3F);
374374
string [string_length ++] = 0x80 | (uchar & 0x3F);
375375
}
376-
376+
377377
break;
378378
}
379379

@@ -421,9 +421,9 @@ json_value * json_parse_ex (json_settings * settings,
421421
case json_object:
422422

423423
if (state.first_pass)
424-
(*(json_char **) &top->u.object.values) += string_length + 1;
424+
*(void **) &top->u.object.values += string_length + 1;
425425
else
426-
{
426+
{
427427
top->u.object.values [top->u.object.length].name
428428
= (json_char *) top->_reserved.object_mem;
429429

@@ -568,7 +568,7 @@ json_value * json_parse_ex (json_settings * settings,
568568
continue;
569569
}
570570
else
571-
{
571+
{
572572
sprintf (error, "%d:%d: Expected : before %c",
573573
state.cur_line, state.cur_col, b);
574574

@@ -706,7 +706,7 @@ json_value * json_parse_ex (json_settings * settings,
706706
switch (top->type)
707707
{
708708
case json_object:
709-
709+
710710
switch (b)
711711
{
712712
whitespace:
@@ -725,7 +725,7 @@ json_value * json_parse_ex (json_settings * settings,
725725
string_length = 0;
726726

727727
break;
728-
728+
729729
case '}':
730730

731731
flags = (flags & ~ flag_need_comma) | flag_next;
@@ -738,6 +738,7 @@ json_value * json_parse_ex (json_settings * settings,
738738
flags &= ~ flag_need_comma;
739739
break;
740740
}
741+
// fall through
741742

742743
default:
743744
sprintf (error, "%d:%d: Unexpected `%c` in object", line_and_col, b);
@@ -893,7 +894,7 @@ json_value * json_parse_ex (json_settings * settings,
893894

894895
if (top->parent->type == json_array)
895896
flags |= flag_seek_value;
896-
897+
897898
if (!state.first_pass)
898899
{
899900
json_value * parent = top->parent;

modding/background_new.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ int __cdecl BGND2_LoadPicture(LPCTSTR fileName, BOOL isTitle, BOOL isReload) {
675675
if( fileName == NULL || *fileName == 0 ) {
676676
goto FAIL;
677677
}
678-
strncpy(lastFileName, fileName, sizeof(lastFileName)); // backup filename string
678+
strncpy(lastFileName, fileName, sizeof(lastFileName)-1); // backup filename string
679679
lastTitleState = isTitle; // backup isTitle state
680680
}
681681

@@ -688,7 +688,7 @@ int __cdecl BGND2_LoadPicture(LPCTSTR fileName, BOOL isTitle, BOOL isReload) {
688688
pickResult = PickBestPictureFile(fullPath, "pix");
689689
}
690690
if( !IsGold() || pickResult < 0 ) {
691-
strncpy(fullPath, GetFullPath(fileName), sizeof(fullPath));
691+
strncpy(fullPath, GetFullPath(fileName), sizeof(fullPath)-1);
692692
pickResult = PickBestPictureFile(fullPath, "pix");
693693
}
694694
#else // !FEATURE_GOLD

modding/file_utils.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017-2019 Michael Chaban. All rights reserved.
2+
* Copyright (c) 2017-2020 Michael Chaban. All rights reserved.
33
* Original game is written by Core Design Ltd. in 1997.
44
* Lara Croft and Tomb Raider are trademarks of Square Enix Ltd.
55
*
@@ -50,7 +50,7 @@ int AutoSelectExtension(LPSTR fileName, const STRING_FIXED4 *exts, DWORD num_ext
5050
char extFileName[256] = {0};
5151
char *extension;
5252

53-
strncpy(extFileName, fileName, sizeof(extFileName));
53+
strncpy(extFileName, fileName, sizeof(extFileName)-1);
5454
extension = PathFindExtension(extFileName);
5555

5656
if( extension == NULL ) {
@@ -61,7 +61,7 @@ int AutoSelectExtension(LPSTR fileName, const STRING_FIXED4 *exts, DWORD num_ext
6161
for( DWORD i = 0; i < num_exts; ++i ) {
6262
memcpy(extension + 1, &exts[i], sizeof(STRING_FIXED4));
6363
if( PathFileExists(extFileName) ) {
64-
strncpy(fileName, extFileName, sizeof(extFileName));
64+
strcpy(fileName, extFileName);
6565
return (i + 1);
6666
}
6767
}
@@ -85,7 +85,7 @@ int AutoSelectPathAndExtension(LPSTR fileName, LPCSTR path, const STRING_FIXED4
8585
ext = AutoSelectExtension(checkFileName, exts, num_exts);
8686

8787
if( ext >= 0 ) {
88-
strncpy(fileName, checkFileName, sizeof(checkFileName));
88+
strcpy(fileName, checkFileName);
8989
return 1;
9090
}
9191
}
@@ -98,7 +98,7 @@ int CreateDirectories(LPCSTR path, bool isFileName) {
9898
char shortPath[MAX_PATH];
9999
char fullPath[MAX_PATH];
100100

101-
strncpy(shortPath, path, sizeof(shortPath));
101+
strncpy(shortPath, path, sizeof(shortPath)-1);
102102
if( isFileName ) {
103103
PathRemoveFileSpec(shortPath);
104104
}

modding/mod_utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ bool LoadModConfiguration(LPCTSTR levelFilePath) {
499499
return false;
500500
}
501501
char levelName[256] = {0};
502-
strncpy(levelName, PathFindFileName(levelFilePath), sizeof(levelName));
502+
strncpy(levelName, PathFindFileName(levelFilePath), sizeof(levelName)-1);
503503
char *ext = PathFindExtension(levelName);
504504
if( ext != NULL ) *ext = 0;
505505

specific/winvid.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,7 @@ LRESULT CALLBACK WinVidGameWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM
987987
case SIZE_MINIMIZED :
988988
IsGameWindowMinimized = true;
989989
IsGameWindowMaximized = false;
990-
// here is no break operator in purpose
990+
// fall through
991991
default :
992992
return DefWindowProc(hWnd, Msg, wParam, lParam);
993993
}

0 commit comments

Comments
 (0)