diff --git a/src/d_netcmd.c b/src/d_netcmd.c index cd8dba956..24d01bef1 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2762,11 +2762,11 @@ static void Command_ReplayMarker(void) if (title) { - snprintf(demo.titlename, 64, "%s [%i:%02d/%.5s]", title, G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername); + snprintf(demo.titlename, sizeof(demo.titlename), "%s [%i:%02d/%.5s]", title, G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername); Z_Free(title); } else - snprintf(demo.titlename, 64, "[%i:%02d/%.5s]", G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername); + snprintf(demo.titlename, sizeof(demo.titlename), "[%i:%02d/%.5s]", G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername); CONS_Printf("Replay will be saved!\n"); } diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index c5ae3b451..e37b9502b 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -1348,7 +1348,7 @@ FUNCNORETURN static ATTRNORETURN void newsignalhandler_Warn(const char *pr) { char text[128]; - snprintf(text, sizeof text, + snprintf(text, sizeof(text), "Error while setting up signal reporting: %s: %s", pr, strerror(errno) @@ -1534,7 +1534,7 @@ FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...) if (errorcount > 20) { va_start(argptr, error); - vsnprintf(buffer, 8192, error, argptr); + vsnprintf(buffer, sizeof(buffer), error, argptr); va_end(argptr); I_OutputMsg("SRB2Kart %s Recursive Error", buffer); @@ -1547,7 +1547,7 @@ FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...) // Display error message in the console before we start shutting it down va_start(argptr, error); - vsnprintf(buffer, 8192, error, argptr); + vsnprintf(buffer, sizeof(buffer), error, argptr); va_end(argptr); I_OutputMsg("\nI_Error(): %s\n", buffer); diff --git a/src/g_demo.c b/src/g_demo.c index b86bbc8f8..cb24999e6 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -1723,11 +1723,11 @@ void G_BeginRecording(void) // Print to a separate temp buffer instead of demo.titlename, so we can use it in M_TextInputSetString if (title) { - snprintf(demotitlename, 64, "%s - %s", title, modeattacking ? "Time Attack" : connectedservername); + snprintf(demotitlename, sizeof(demotitlename), "%s - %s", title, modeattacking ? "Time Attack" : connectedservername); Z_Free(title); } else - snprintf(demotitlename, 64, "%s", modeattacking ? "Time Attack" : connectedservername); + snprintf(demotitlename, sizeof(demotitlename), "%s", modeattacking ? "Time Attack" : connectedservername); // Init just in case it isn't initialized already M_TextInputInit(&demo.titlenameinput, demo.titlename, sizeof(demo.titlename)); @@ -2213,7 +2213,6 @@ void G_LoadDemoInfo(menudemo_t *pdemo) CONS_Alert(CONS_ERROR, M_GetText("Failed to read file '%s'.\n"), pdemo->filepath); pdemo->type = MD_INVALID; snprintf(pdemo->title, sizeof(pdemo->title), "INVALID REPLAY"); - return; } @@ -2634,7 +2633,7 @@ void G_DoPlayDemo(char *defdemoname) //FIL_DefaultExtension(defdemoname, ".lmp"); if (!FIL_ReadFile(defdemoname, &demobuf.buffer)) { - snprintf(msg, 1024, M_GetText("Failed to read file '%s'.\n"), defdemoname); + snprintf(msg, sizeof(msg), M_GetText("Failed to read file '%s'.\n"), defdemoname); CONS_Alert(CONS_ERROR, "%s", msg); gameaction = ga_nothing; M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); @@ -2646,7 +2645,7 @@ void G_DoPlayDemo(char *defdemoname) // load demo resource from WAD else if ((l = W_CheckNumForName(defdemoname)) == LUMPERROR) { - snprintf(msg, 1024, M_GetText("Failed to read lump '%s'.\n"), defdemoname); + snprintf(msg, sizeof(msg), M_GetText("Failed to read lump '%s'.\n"), defdemoname); CONS_Alert(CONS_ERROR, "%s", msg); gameaction = ga_nothing; M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); @@ -2667,7 +2666,7 @@ void G_DoPlayDemo(char *defdemoname) if (memcmp(demobuf.p, DEMOHEADER, 12)) { - snprintf(msg, 1024, M_GetText("%s is not a SRB2Kart replay file.\n"), pdemoname); + snprintf(msg, sizeof(msg), M_GetText("%s is not a SRB2Kart replay file.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); G_ResetDemoPlayback(); @@ -2693,7 +2692,7 @@ void G_DoPlayDemo(char *defdemoname) #endif // too old, cannot support. default: - snprintf(msg, 1024, M_GetText("%s is an incompatible replay format and cannot be played.\n"), pdemoname); + snprintf(msg, sizeof(msg), M_GetText("%s is an incompatible replay format and cannot be played.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); G_ResetDemoPlayback(); @@ -2704,7 +2703,7 @@ void G_DoPlayDemo(char *defdemoname) if (memcmp(demobuf.p, "PLAY", 4)) { - snprintf(msg, 1024, M_GetText("%s is the wrong type of recording and cannot be played.\n"), pdemoname); + snprintf(msg, sizeof(msg), M_GetText("%s is the wrong type of recording and cannot be played.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); G_ResetDemoPlayback(); @@ -2721,7 +2720,7 @@ void G_DoPlayDemo(char *defdemoname) { if (demoflags & DF_MULTIPLAYER) { - snprintf(msg, 1024, M_GetText("%s is an alpha multiplayer replay and cannot be played.\n"), pdemoname); + snprintf(msg, sizeof(msg), M_GetText("%s is an alpha multiplayer replay and cannot be played.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); G_ResetDemoPlayback(); @@ -2748,31 +2747,31 @@ void G_DoPlayDemo(char *defdemoname) switch (error) { case DFILE_ERROR_NOTLOADED: - snprintf(msg, 1024, + snprintf(msg, sizeof(msg), "Required files for this demo are not loaded.\n\nUse\n\"playdemo %s -addfiles\"\nto load them and play the demo.\n", pdemoname); break; case DFILE_ERROR_OUTOFORDER: - snprintf(msg, 1024, + snprintf(msg, sizeof(msg), "Required files for this demo are loaded out of order.\n\nUse\n\"playdemo %s -force\"\nto play the demo anyway.\n", pdemoname); break; case DFILE_ERROR_INCOMPLETEOUTOFORDER: - snprintf(msg, 1024, + snprintf(msg, sizeof(msg), "Required files for this demo are not loaded, and some are out of order.\n\nUse\n\"playdemo %s -addfiles\"\nto load needed files and play the demo.\n", pdemoname); break; case DFILE_ERROR_CANNOTLOAD: - snprintf(msg, 1024, + snprintf(msg, sizeof(msg), "Required files for this demo cannot be loaded.\n\nUse\n\"playdemo %s -force\"\nto play the demo anyway.\n", pdemoname); break; case DFILE_ERROR_EXTRAFILES: - snprintf(msg, 1024, + snprintf(msg, sizeof(msg), "You have additional files loaded beyond the demo's file list.\n\nUse\n\"playdemo %s -force\"\nto play the demo anyway.\n", pdemoname); break; @@ -2822,7 +2821,7 @@ void G_DoPlayDemo(char *defdemoname) // ...*map* not loaded? if (!gamemap || (gamemap > NUMMAPS) || (W_CheckNumForName(G_BuildMapName(gamemap)) == LUMPERROR)) { - snprintf(msg, 1024, M_GetText("%s features a course that is not currently loaded.\n"), pdemoname); + snprintf(msg, sizeof(msg), M_GetText("%s features a course that is not currently loaded.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); G_ResetDemoPlayback(); @@ -2854,7 +2853,7 @@ void G_DoPlayDemo(char *defdemoname) // Skin not loaded? if (!SetPlayerSkin(0, skin)) { - snprintf(msg, 1024, M_GetText("%s features a character that is not currently loaded.\n"), pdemoname); + snprintf(msg, sizeof(msg), M_GetText("%s features a character that is not currently loaded.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); G_ResetDemoPlayback(); @@ -2864,7 +2863,7 @@ void G_DoPlayDemo(char *defdemoname) // ...*map* not loaded? if (!gamemap || (gamemap > NUMMAPS) || !mapheaderinfo[gamemap-1] || !(mapheaderinfo[gamemap-1]->menuflags & LF2_EXISTSHACK)) { - snprintf(msg, 1024, M_GetText("%s features a course that is not currently loaded.\n"), pdemoname); + snprintf(msg, sizeof(msg), M_GetText("%s features a course that is not currently loaded.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); G_ResetDemoPlayback(); @@ -2887,7 +2886,7 @@ void G_DoPlayDemo(char *defdemoname) // Sigh ... it's an empty demo. if (*demobuf.p == DEMOMARKER) { - snprintf(msg, 1024, M_GetText("%s contains no data to be played.\n"), pdemoname); + snprintf(msg, sizeof(msg), M_GetText("%s contains no data to be played.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); G_ResetDemoPlayback(); @@ -2925,7 +2924,7 @@ void G_DoPlayDemo(char *defdemoname) // Sigh ... it's an empty demo. if (*demobuf.p == DEMOMARKER) { - snprintf(msg, 1024, M_GetText("%s contains no data to be played.\n"), pdemoname); + snprintf(msg, sizeof(msg), M_GetText("%s contains no data to be played.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); G_ResetDemoPlayback(); @@ -2974,7 +2973,7 @@ void G_DoPlayDemo(char *defdemoname) if (modeattacking) { - snprintf(msg, 1024, M_GetText("%s is a Record Attack replay with spectators, and is thus invalid.\n"), pdemoname); + snprintf(msg, sizeof(msg), M_GetText("%s is a Record Attack replay with spectators, and is thus invalid.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); G_ResetDemoPlayback(); @@ -2986,7 +2985,7 @@ void G_DoPlayDemo(char *defdemoname) if (modeattacking && numslots > 1) { - snprintf(msg, 1024, M_GetText("%s is a Record Attack replay with multiple players, and is thus invalid.\n"), pdemoname); + snprintf(msg, sizeof(msg), M_GetText("%s is a Record Attack replay with multiple players, and is thus invalid.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); G_ResetDemoPlayback(); diff --git a/src/g_game.c b/src/g_game.c index c2b6499f9..9cc58d19e 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3849,7 +3849,7 @@ void G_SaveGame(UINT32 savegameslot) savebuffer_t save = {}; snprintf(savename, sizeof(savename), savegamename, savegameslot); - backup = va("%s",savename); + backup = va("%s", savename); // save during evaluation or credits? game's over, folks! if (gamestate == GS_CREDITS || gamestate == GS_EVALUATION) @@ -3867,7 +3867,7 @@ void G_SaveGame(UINT32 savegameslot) return; } - memset(name, 0, sizeof (name)); + memset(name, 0, sizeof(name)); snprintf(name, sizeof(name), "version %d", VERSION); WRITEMEM(save.p, name, VERSIONSIZE); diff --git a/src/k_hud.c b/src/k_hud.c index 71bd018c0..545cd957a 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -1974,7 +1974,7 @@ void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UI goto bademblem; } - snprintf(targettext, 9, "%i'%02i\"%02i", + snprintf(targettext, sizeof(targettext), "%i'%02i\"%02i", G_TicsToMinutes(timetoreach, false), G_TicsToSeconds(timetoreach), G_TicsToCentiseconds(timetoreach)); diff --git a/src/lua_script.c b/src/lua_script.c index eb78cd201..0943eef68 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -277,14 +277,14 @@ void LUA_LoadLump(UINT16 wad, UINT16 lump) if (wadfiles[wad]->type == RET_LUA) { - name = malloc(len+1); - strcpy(name, wadfiles[wad]->filename); + name = malloc(len + 1); + snprintf(name, len + 1, "%s", wadfiles[wad]->filename); } else // If it's not a .lua file, copy the lump name in too. { lumpinfo_t *lump_p = &wadfiles[wad]->lumpinfo[lump]; len += 1 + strlen(lump_p->fullname); // length of file name, '|', and lump name - name = malloc(len+1); + name = malloc(len + 1); if (!name) I_Error("LUA_LoadLump: Out of memory!\n"); diff --git a/src/m_misc.c b/src/m_misc.c index 41dea5517..a8dc0269d 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -515,8 +515,8 @@ static boolean M_BackupConfig(const char *filename) { char backupfile[MAX_WADPATH+4]; - snprintf(backupfile, sizeof backupfile, "%s.bak", filename); - backupfile[sizeof backupfile - 1] = '\0'; + snprintf(backupfile, sizeof(backupfile), "%s.bak", filename); + backupfile[sizeof(backupfile) - 1] = '\0'; FILE *config = fopen(filename, "r"); @@ -766,27 +766,27 @@ static void M_PNGText(png_structp png_ptr, png_infop png_info_ptr, PNG_CONST png } if (gamestate == GS_LEVEL) - snprintf(maptext, 8, "%s", G_BuildMapName(gamemap)); + snprintf(maptext, sizeof(maptext), "%s", G_BuildMapName(gamemap)); else - snprintf(maptext, 8, "Unknown"); + snprintf(maptext, sizeof(maptext), "Unknown"); if (gamestate == GS_LEVEL && mapheaderinfo[gamemap-1]->lvlttl[0] != '\0') - snprintf(lvlttltext, 48, "%s%s%s", + snprintf(lvlttltext, sizeof(lvlttltext), "%s%s%s", mapheaderinfo[gamemap-1]->lvlttl, (strlen(mapheaderinfo[gamemap-1]->zonttl) > 0) ? va(" %s",mapheaderinfo[gamemap-1]->zonttl) : // SRB2kart ((mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE) ? "" : " ZONE"), (strlen(mapheaderinfo[gamemap-1]->actnum) > 0) ? va(" %s",mapheaderinfo[gamemap-1]->actnum) : ""); else - snprintf(lvlttltext, 48, "Unknown"); + snprintf(lvlttltext, sizeof(lvlttltext), "Unknown"); if (gamestate == GS_LEVEL && players[displayplayers[0]].mo) - snprintf(locationtxt, 40, "X:%d Y:%d Z:%d A:%d", + snprintf(locationtxt, sizeof(locationtxt), "X:%d Y:%d Z:%d A:%d", players[displayplayers[0]].mo->x>>FRACBITS, players[displayplayers[0]].mo->y>>FRACBITS, players[displayplayers[0]].mo->z>>FRACBITS, FixedInt(AngleFixed(players[displayplayers[0]].mo->angle))); else - snprintf(locationtxt, 40, "Unknown"); + snprintf(locationtxt, sizeof(locationtxt), "Unknown"); memset(png_infotext, 0x00, sizeof(png_infotext)); @@ -1393,7 +1393,7 @@ char *va(const char *format, ...) static char string[1024]; va_start(argptr, format); - vsnprintf(string, 1024, format, argptr); + vsnprintf(string, sizeof(string), format, argptr); va_end(argptr); return string; @@ -1735,6 +1735,7 @@ UINT8 M_CountBits(UINT32 num, UINT8 size) const char *GetRevisionString(void) { static char rev[9] = {0}; + if (rev[0]) return rev; @@ -1742,6 +1743,7 @@ const char *GetRevisionString(void) strncpy(rev, comprevision, 7); else snprintf(rev, 7, "r%s", comprevision); + rev[7] = '\0'; return rev; diff --git a/src/p_setup.c b/src/p_setup.c index 1d9586406..17a0b9d77 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -266,8 +266,8 @@ static void P_ClearSingleMapHeaderInfo(INT16 i) mapheaderinfo[num]->actnum[0] = '\0'; mapheaderinfo[num]->typeoflevel = 0; mapheaderinfo[num]->nextlevel = (INT16)(i + 1); - snprintf(mapheaderinfo[num]->musname, 7, "%sM", G_BuildMapName(i)); - mapheaderinfo[num]->musname[6] = 0; + snprintf(mapheaderinfo[num]->musname, sizeof(mapheaderinfo[num]->musname), "%sM", G_BuildMapName(i)); + mapheaderinfo[num]->musname[sizeof(mapheaderinfo[num]->musname)-1] = 0; mapheaderinfo[num]->mustrack = 0; mapheaderinfo[num]->muspos = 0; mapheaderinfo[num]->forcecharacter[0] = '\0'; @@ -3065,7 +3065,7 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) // Don't include these in the fade! char tx[64]; V_DrawSmallString(1, 191, V_ALLOWLOWERCASE, M_GetText("Speeding off to...")); - snprintf(tx, 63, "%s%s%s", + snprintf(tx, sizeof(tx), "%s%s%s", mapheader->lvlttl, (strlen(mapheader->zonttl) > 0) ? va(" %s",mapheader->zonttl) : // SRB2kart ((mapheader->levelflags & LF_NOZONE) ? "" : " Zone"), diff --git a/src/s_sound.c b/src/s_sound.c index a1165cbdf..d7f4a2853 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -2193,7 +2193,7 @@ static void Command_Tunes_f(void) track = (UINT16)atoi(COM_Argv(2))-1; if (tunenum) - snprintf(mapmusic.name, 7, "%sM", G_BuildMapName(tunenum)); + snprintf(mapmusic.name, sizeof(mapmusic.name), "%sM", G_BuildMapName(tunenum)); else strlcpy(mapmusic.name, tunearg, sizeof(mapmusic.name)); diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index a505f7002..ae009928b 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -1278,7 +1278,7 @@ static void I_SetupMumble(void) int shmfd; char memname[256]; - snprintf(memname, 256, "/MumbleLink.%d", getuid()); + snprintf(memname, sizeof(memname), "/MumbleLink.%d", getuid()); shmfd = shm_open(memname, O_RDWR, S_IRUSR | S_IWUSR); if (shmfd < 0) @@ -1887,7 +1887,7 @@ FUNCNORETURN static ATTRNORETURN void newsignalhandler_Warn(const char *pr) { char text[128]; - snprintf(text, sizeof text, + snprintf(text, sizeof(text), "Error while setting up signal reporting: %s: %s", pr, strerror(errno) @@ -2103,7 +2103,7 @@ FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...) if (errorcount > 20) { va_start(argptr, error); - vsnprintf(buffer, 8192, error, argptr); + vsnprintf(buffer, sizeof(buffer), error, argptr); va_end(argptr); sigttl = "SRB2Kart " VERSIONSTRING " Recursive Error"; @@ -2117,7 +2117,7 @@ FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...) // Display error message in the console before we start shutting it down va_start(argptr, error); - vsnprintf(buffer, 8192, error, argptr); + vsnprintf(buffer, sizeof(buffer), error, argptr); va_end(argptr); I_OutputMsg("\nI_Error(): %s\n", buffer); diff --git a/src/y_inter.c b/src/y_inter.c index bcb6a649e..4ea042aa7 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -369,9 +369,9 @@ static void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) if (standings->increase[pnum] != UINT8_MAX) { if (standings->increase[pnum] > 9) - snprintf(strtime, sizeof strtime, "(+%02d)", standings->increase[pnum]); + snprintf(strtime, sizeof(strtime), "(+%02d)", standings->increase[pnum]); else - snprintf(strtime, sizeof strtime, "(+ %d)", standings->increase[pnum]); + snprintf(strtime, sizeof(strtime), "(+ %d)", standings->increase[pnum]); if (standings->numplayers > NUMFORNEWCOLUMN) V_DrawRightAlignedThinString(x+135+gutter, y-1, V_6WIDTHSPACE, strtime); @@ -379,7 +379,7 @@ static void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) V_DrawRightAlignedString(x+120+gutter, y, 0, strtime); } - snprintf(strtime, sizeof strtime, "%d", standings->val[i]); + snprintf(strtime, sizeof(strtime), "%d", standings->val[i]); if (standings->numplayers > NUMFORNEWCOLUMN) V_DrawRightAlignedThinString(x+152+gutter, y-1, V_6WIDTHSPACE, strtime); @@ -394,9 +394,9 @@ static void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) { if (intertype == int_race) { - snprintf(strtime, sizeof strtime, "%i'%02i\"%02i", G_TicsToMinutes(standings->val[i], true), + snprintf(strtime, sizeof(strtime), "%i'%02i\"%02i", G_TicsToMinutes(standings->val[i], true), G_TicsToSeconds(standings->val[i]), G_TicsToCentiseconds(standings->val[i])); - strtime[sizeof strtime - 1] = '\0'; + strtime[sizeof(strtime) - 1] = '\0'; if (standings->numplayers > NUMFORNEWCOLUMN) V_DrawRightAlignedThinString(x+152+gutter, y-1, V_6WIDTHSPACE, strtime); @@ -663,14 +663,14 @@ static void Y_UpdateRecordReplays(void) snprintf(gpath, glen, "%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, G_BuildMapName(gamemap)); - snprintf(lastdemo, 255, "%s-%s-last.lmp", gpath, cv_chooseskin.string); + snprintf(lastdemo, sizeof(lastdemo), "%s-%s-last.lmp", gpath, cv_chooseskin.string); if (FIL_FileExists(lastdemo)) { UINT8 *buf; size_t len = FIL_ReadFile(lastdemo, &buf); - snprintf(bestdemo, 255, "%s-%s-time-best.lmp", gpath, cv_chooseskin.string); + snprintf(bestdemo, sizeof(bestdemo), "%s-%s-time-best.lmp", gpath, cv_chooseskin.string); if (!FIL_FileExists(bestdemo) || G_CmpDemoTime(bestdemo, lastdemo) & 1) { // Better time, save this demo. if (FIL_FileExists(bestdemo)) @@ -679,7 +679,7 @@ static void Y_UpdateRecordReplays(void) CONS_Printf("\x83%s\x80 %s '%s'\n", M_GetText("NEW RECORD TIME!"), M_GetText("Saved replay as"), bestdemo); } - snprintf(bestdemo, 255, "%s-%s-lap-best.lmp", gpath, cv_chooseskin.string); + snprintf(bestdemo, sizeof(bestdemo), "%s-%s-lap-best.lmp", gpath, cv_chooseskin.string); if (!FIL_FileExists(bestdemo) || G_CmpDemoTime(bestdemo, lastdemo) & (1<<1)) { // Better lap time, save this demo. if (FIL_FileExists(bestdemo)) @@ -1509,12 +1509,12 @@ void Y_StartVote(void) { if (mapheaderinfo[votelevels[i][0]]->actnum[0]) snprintf(levelinfo[i].str, - sizeof levelinfo[i].str, + sizeof(levelinfo[i].str), "%s %s", mapheaderinfo[votelevels[i][0]]->lvlttl, mapheaderinfo[votelevels[i][0]]->actnum); else snprintf(levelinfo[i].str, - sizeof levelinfo[i].str, + sizeof(levelinfo[i].str), "%s", mapheaderinfo[votelevels[i][0]]->lvlttl); } @@ -1522,12 +1522,12 @@ void Y_StartVote(void) { if (mapheaderinfo[votelevels[i][0]]->actnum[0]) snprintf(levelinfo[i].str, - sizeof levelinfo[i].str, + sizeof(levelinfo[i].str), "%s %s %s", mapheaderinfo[votelevels[i][0]]->lvlttl, mapheaderinfo[votelevels[i][0]]->zonttl, mapheaderinfo[votelevels[i][0]]->actnum); else snprintf(levelinfo[i].str, - sizeof levelinfo[i].str, + sizeof(levelinfo[i].str), "%s %s", mapheaderinfo[votelevels[i][0]]->lvlttl, mapheaderinfo[votelevels[i][0]]->zonttl); }