diff --git a/CMakeLists.txt b/CMakeLists.txt index 82b50d8..bc841a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -234,6 +234,8 @@ endif() target_compile_options(quake PUBLIC $<$: -Wall -Wextra -Werror -Wno-missing-field-initializers> + # why are these even warnings? + $<$: -Wno-array-bounds -Wno-stringop-truncation> $<$: /W4>) target_include_directories(quake SYSTEM PUBLIC ${SDL2_INCLUDE_DIRS}) target_include_directories(quake PUBLIC source) diff --git a/source/gl_draw.c b/source/gl_draw.c index 710d87f..86eaed7 100644 --- a/source/gl_draw.c +++ b/source/gl_draw.c @@ -225,7 +225,7 @@ qpic_t *Draw_PicFromWad(const char *name) // load little ones into the scrap if(p->width < 64 && p->height < 64) { - int32_t x, y; + int32_t x = 0, y = 0; int32_t i, j, k; int32_t texnum; diff --git a/source/gl_screen.c b/source/gl_screen.c index b0cabbc..acc5aea 100644 --- a/source/gl_screen.c +++ b/source/gl_screen.c @@ -776,22 +776,20 @@ SCR_ScreenShot_f -- johnfitz -- rewritten to use Image_WriteTGA void SCR_ScreenShot_f(void) { byte *buffer; - char ext[4]; + char ext[4] = "png"; char imagename[16]; //johnfitz -- was [80] char checkname[MAX_OSPATH]; int32_t i, quality; bool ok; - strncpy(ext, "png", sizeof(ext)); - if(Cmd_Argc() >= 2) { const char *requested_ext = Cmd_Argv(1); - if(!q_strcasecmp("png", requested_ext) - || !q_strcasecmp("tga", requested_ext) - || !q_strcasecmp("jpg", requested_ext)) - strncpy(ext, requested_ext, sizeof(ext)); + if(!q_strcasecmp("png", requested_ext) || + !q_strcasecmp("tga", requested_ext) || + !q_strcasecmp("jpg", requested_ext)) + strncpy(ext, requested_ext, strsizeof(ext)); else { SCR_ScreenShot_Usage(); diff --git a/source/keys.c b/source/keys.c index a970b3b..0b03c4b 100644 --- a/source/keys.c +++ b/source/keys.c @@ -219,7 +219,7 @@ static void PasteToConsole(void) // insert the string if(mvlen != 0) - memmove(workline + inslen, workline, mvlen); + memmove(&workline[inslen], workline, mvlen); memcpy(workline, cbd, inslen); key_linepos += inslen; workline[mvlen + inslen] = '\0'; @@ -249,7 +249,7 @@ void Key_Console(int32_t key) case K_ENTER: case K_KP_ENTER: key_tabpartial[0] = 0; - Cbuf_AddText(workline + 1); // skip the prompt + Cbuf_AddText(&workline[1]); // skip the prompt Cbuf_AddText("\n"); Con_Printf("%s\n", workline); @@ -278,9 +278,10 @@ void Key_Console(int32_t key) if(workline[1]) { len = strlen(workline); - memmove(workline, workline + 1, len); + memmove(workline, &workline[1], len); } - else *workline = 0; + else + workline[0] = 0; key_linepos--; } return; @@ -288,14 +289,15 @@ void Key_Console(int32_t key) case K_DEL: key_tabpartial[0] = 0; workline += key_linepos; - if(*workline) + if(workline[0]) { if(workline[1]) { len = strlen(workline); - memmove(workline, workline + 1, len); + memmove(workline, &workline[1], len); } - else *workline = 0; + else + workline[0] = 0; } return; @@ -358,7 +360,7 @@ void Key_Console(int32_t key) if((int32_t)len <= key_linepos) return; // no character to get workline += key_linepos; - *workline = key_lines[(edit_line + 31) & 31][key_linepos]; + workline[0] = key_lines[(edit_line + 31) & 31][key_linepos]; workline[1] = 0; key_linepos++; } @@ -371,7 +373,7 @@ void Key_Console(int32_t key) case K_UPARROW: if(history_line == edit_line) - strcpy(current, workline); + memmove(current, workline, MAXCMDLINE); history_line_last = history_line; do @@ -387,7 +389,7 @@ void Key_Console(int32_t key) } key_tabpartial[0] = 0; - strcpy(workline, key_lines[history_line]); + memmove(workline, key_lines[history_line], MAXCMDLINE); key_linepos = strlen(workline); return; @@ -404,8 +406,9 @@ void Key_Console(int32_t key) while(history_line != edit_line && !key_lines[history_line][1]); if(history_line == edit_line) - strcpy(workline, current); - else strcpy(workline, key_lines[history_line]); + memmove(workline, current, MAXCMDLINE); + else + memmove(workline, key_lines[history_line], MAXCMDLINE); key_linepos = strlen(workline); return; @@ -462,13 +465,13 @@ void Char_Console(int32_t key) workline[MAXCMDLINE - 2] = 0; workline += key_linepos; len = strlen(workline) + 1; - memmove(workline + 1, workline, len); - *workline = key; + memmove(&workline[1], workline, len); + workline[0] = key; } else { workline += key_linepos; - *workline = key; + workline[0] = key; // null terminate if at the end if(endpos) workline[1] = 0; diff --git a/source/keys.h b/source/keys.h index 6d26d11..4bb6ffd 100644 --- a/source/keys.h +++ b/source/keys.h @@ -156,14 +156,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define MAX_KEYS 256 -#define MAXCMDLINE 256 - typedef enum {key_game, key_console, key_message, key_menu} keydest_t; extern keydest_t key_dest; extern char *keybindings[MAX_KEYS]; -#define CMDLINES 64 +#define MAXCMDLINE 256 +#define CMDLINES 64 extern char key_lines[CMDLINES][MAXCMDLINE]; extern int32_t edit_line; diff --git a/source/wad.c b/source/wad.c index 6ce01d5..e997138 100644 --- a/source/wad.c +++ b/source/wad.c @@ -87,8 +87,7 @@ void W_LoadWadFile(void) //johnfitz -- filename is now hard-coded for honesty header = (wadinfo_t *)wad_base; - if(header->identification[0] != 'W' || header->identification[1] != 'A' - || header->identification[2] != 'D' || header->identification[3] != '2') + if(header->identification[0] != 'W' || header->identification[1] != 'A' || header->identification[2] != 'D' || header->identification[3] != '2') Sys_Error("Wad file %s doesn't have WAD2 id\n", filename); wad_numlumps = LittleLong(header->numlumps);