From 8af4a67f5e29aa95d9ef0f787c4b1fd69a3f407b Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 31 Dec 2023 01:01:03 +0300 Subject: [PATCH] More warning fixes --- src/hardware/hw_md2.c | 16 ++++++++-------- src/hardware/r_opengl/r_opengl.c | 6 +++--- src/lua_hooklib.c | 32 +++++++++++++++++++++----------- src/m_menu.c | 25 ++++++++++++------------- src/m_misc.c | 16 ++++++++-------- src/p_setup.c | 7 ++++--- src/w_wad.c | 2 +- 7 files changed, 57 insertions(+), 47 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 9cd077588..9aa7e1cce 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1254,30 +1254,30 @@ void HWR_DrawMD2(gr_vissprite_t *spr) md2->blendgrpatch && ((GLPatch_t *)md2->blendgrpatch)->mipmap->grInfo.format && gpatch->width == ((GLPatch_t *)md2->blendgrpatch)->width && gpatch->height == ((GLPatch_t *)md2->blendgrpatch)->height) { - INT32 skinnum = TC_DEFAULT; + INT32 tcskinnum = TC_DEFAULT; if ((spr->mobj->flags & MF_BOSS) && (spr->mobj->flags2 & MF2_FRET) && (leveltime & 1)) // Bosses "flash" { if (spr->mobj->type == MT_CYBRAKDEMON) - skinnum = TC_ALLWHITE; + tcskinnum = TC_ALLWHITE; else if (spr->mobj->type == MT_METALSONIC_BATTLE) - skinnum = TC_METALSONIC; + tcskinnum = TC_METALSONIC; else - skinnum = TC_BOSS; + tcskinnum = TC_BOSS; } else if (spr->mobj->color) { if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY) { if (spr->mobj->colorized) - skinnum = TC_RAINBOW; + tcskinnum = TC_RAINBOW; else { - skinnum = (INT32)((skin_t*)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ) - ( (spr->mobj->skinlocal) ? localskins : skins )); + tcskinnum = (INT32)((skin_t*)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ) - ( (spr->mobj->skinlocal) ? localskins : skins )); } } - else skinnum = TC_DEFAULT; + else tcskinnum = TC_DEFAULT; } - HWR_GetBlendedTexture(gpatch, (GLPatch_t *)md2->blendgrpatch, skinnum, spr->colormap, (skincolors_t)spr->mobj->color); + HWR_GetBlendedTexture(gpatch, (GLPatch_t *)md2->blendgrpatch, tcskinnum, spr->colormap, (skincolors_t)spr->mobj->color); } else { diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 580d6e320..9ae935077 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -3191,7 +3191,7 @@ static void gld_BuildSky(int row_count, int col_count) // //----------------------------------------------------------------------------- -static void RenderDome(INT32 skytexture) +static void RenderDome(INT32 skytexnum) { int i, j; int vbosize; @@ -3203,7 +3203,7 @@ static void RenderDome(INT32 skytexture) vbosize = 2 * rows * (columns * 2 + 2) + columns * 2; // Build the sky dome! Yes! - if (lasttex != skytexture) + if (lasttex != skytexnum) { // delete VBO when already exists if (gl_ext_arb_vertex_buffer_object) @@ -3212,7 +3212,7 @@ static void RenderDome(INT32 skytexture) pglDeleteBuffers(1, &vbo->id); } - lasttex = skytexture; + lasttex = skytexnum; gld_BuildSky(rows, columns); if (gl_ext_arb_vertex_buffer_object) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 1e6a5cb29..458dbc09a 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -476,12 +476,14 @@ void LUAh_ThinkFrame(void) // variables used by perf stats int hook_index = 0; precise_t time_taken = 0; + if (!gL || !(hooksAvailable[hook_ThinkFrame/8] & (1<<(hook_ThinkFrame%8)))) return; - + lua_pushcfunction(gL, LUA_GetErrorMessage); for (hookp = roothook; hookp; hookp = hookp->next) + { if (hookp->type == hook_ThinkFrame) { if (cv_perfstats.value == 3) @@ -506,8 +508,9 @@ void LUAh_ThinkFrame(void) hook_index++; } } - - lua_pop(gL, 1); // Pop error handler + } + + lua_pop(gL, 1); // Pop error handler } // Hook for frame (at end of tick, ie after overlays, precipitation, specials) @@ -519,13 +522,13 @@ void LUAh_PostThinkFrame(void) precise_t time_taken = 0; if (!gL || !(hooksAvailable[hook_PostThinkFrame/8] & (1<<(hook_PostThinkFrame%8)))) return; - + lua_pushcfunction(gL, LUA_GetErrorMessage); for (hookp = roothook; hookp; hookp = hookp->next) { if (hookp->type == hook_PostThinkFrame) - { + { if (cv_perfstats.value == 5) time_taken = I_GetPreciseTime(); lua_pushfstring(gL, FMT_HOOKID, hookp->id); @@ -549,6 +552,7 @@ void LUAh_PostThinkFrame(void) } } } + lua_pop(gL, 1); // Pop error handler } @@ -556,12 +560,14 @@ void LUAh_PostThinkFrame(void) void LUAh_IntermissionThinker(void) { hook_p hookp; + if (!gL || !(hooksAvailable[hook_IntermissionThinker/8] & (1<<(hook_IntermissionThinker%8)))) return; - + lua_pushcfunction(gL, LUA_GetErrorMessage); for (hookp = roothook; hookp; hookp = hookp->next) + { if (hookp->type == hook_IntermissionThinker) { lua_pushfstring(gL, FMT_HOOKID, hookp->id); @@ -573,20 +579,23 @@ void LUAh_IntermissionThinker(void) hookp->error = true; } } - - lua_pop(gL, 1); // Pop error handler + } + + lua_pop(gL, 1); // Pop error handler } // Hook for Y_VoteTicker void LUAh_VoteThinker(void) { hook_p hookp; + if (!gL || !(hooksAvailable[hook_VoteThinker/8] & (1<<(hook_VoteThinker%8)))) return; - + lua_pushcfunction(gL, LUA_GetErrorMessage); for (hookp = roothook; hookp; hookp = hookp->next) + { if (hookp->type == hook_VoteThinker) { lua_pushfstring(gL, FMT_HOOKID, hookp->id); @@ -598,8 +607,9 @@ void LUAh_VoteThinker(void) hookp->error = true; } } - - lua_pop(gL, 1); // Pop error handler + } + + lua_pop(gL, 1); // Pop error handler } diff --git a/src/m_menu.c b/src/m_menu.c index 9c57a3d36..074da4061 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4783,11 +4783,11 @@ static void M_DrawSplitText(INT32 x, INT32 y, INT32 option, const char* str, INT if (icopy == NULL) return; - char* token = strtok(icopy, "\n"); + char* tok = strtok(icopy, "\n"); - while (token != NULL) + while (tok != NULL) { - char* line = strdup(token); + char* line = strdup(tok); if (line == NULL) return; @@ -4795,7 +4795,7 @@ static void M_DrawSplitText(INT32 x, INT32 y, INT32 option, const char* str, INT clines[num_lines] = line; num_lines++; - token = strtok(NULL, "\n"); + tok = strtok(NULL, "\n"); } free(icopy); @@ -6090,7 +6090,7 @@ static void M_AddonsOptions(INT32 choice) #define LOCATIONSTRING1 "Visit \x83SRB2.ORG/MODS\x80 to get & make addons!" #define LOCATIONSTRING2 "Visit \x88SRB2.ORG/MODS\x80 to get & make addons!" -static void M_AddonsInternal() +static void M_AddonsInternal(void) { const char *pathname = "."; @@ -11726,7 +11726,6 @@ static void M_DrawSetupMultiPlayerMenu(void) if (statdp == true) { - int i; //Background V_DrawScaledPatch(statx - 50, staty + 4, 0, W_CachePatchName("K_STATNB", PU_CACHE)); @@ -12027,22 +12026,22 @@ static void M_DrawSetupMultiPlayerMenu(void) INT32 j = -colwidth; INT16 col = setupm_fakecolor - colwidth; INT32 x = mx; - INT32 w = indexwidth; - UINT8 h; + INT32 cw = indexwidth; + UINT8 ch; while (col < 1) col += MAXSKINCOLORS-1; while (j <= colwidth) { if (!(j++)) - w = charw; + cw = charw; else - w = indexwidth; - for (h = 0; h < 16; h++) - V_DrawFill(x, my+(cv_skinselectmenu.value?176:162)+h, w, 1, colortranslations[col][h]); + cw = indexwidth; + for (ch = 0; ch < 16; ch++) + V_DrawFill(x, my+(cv_skinselectmenu.value?176:162)+ch, cw, 1, colortranslations[col][ch]); if (++col >= MAXSKINCOLORS) col -= MAXSKINCOLORS-1; - x += w; + x += cw; } } #undef indexwidth diff --git a/src/m_misc.c b/src/m_misc.c index db41f291a..39f3b46fe 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -62,11 +62,11 @@ typedef off_t off64_t; #endif #if defined(__MINGW32__) && ((__GNUC__ > 7) || (__GNUC__ == 6 && __GNUC_MINOR__ >= 3)) && (__GNUC__ < 8) -#define PRIdS "u" +#define PRIdS "%u" #elif defined(_WIN32) && !defined(__MINGW64__) -#define PRIdS "Iu" +#define PRIdS "%Iu" #else -#define PRIdS "zu" +#define PRIdS "%zu" #endif #ifdef HAVE_PNG @@ -1905,35 +1905,35 @@ TMatrix *RotateZMatrix(angle_t rad) char *sizeu1(size_t num) { static char sizeu1_buf[28]; - sprintf(sizeu1_buf, "%"PRIdS, num); + sprintf(sizeu1_buf, PRIdS, num); return sizeu1_buf; } char *sizeu2(size_t num) { static char sizeu2_buf[28]; - sprintf(sizeu2_buf, "%"PRIdS, num); + sprintf(sizeu2_buf, PRIdS, num); return sizeu2_buf; } char *sizeu3(size_t num) { static char sizeu3_buf[28]; - sprintf(sizeu3_buf, "%"PRIdS, num); + sprintf(sizeu3_buf, PRIdS, num); return sizeu3_buf; } char *sizeu4(size_t num) { static char sizeu4_buf[28]; - sprintf(sizeu4_buf, "%"PRIdS, num); + sprintf(sizeu4_buf, PRIdS, num); return sizeu4_buf; } char *sizeu5(size_t num) { static char sizeu5_buf[28]; - sprintf(sizeu5_buf, "%"PRIdS, num); + sprintf(sizeu5_buf, PRIdS, num); return sizeu5_buf; } diff --git a/src/p_setup.c b/src/p_setup.c index 40601dc5f..1bc232fad 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -553,17 +553,18 @@ levelflat_t *levelflats; size_t P_PrecacheLevelFlats(void) { lumpnum_t lump; - size_t i, flatmemory = 0; + size_t i, flatmem = 0; //SoM: 4/18/2000: New flat code to make use of levelflats. for (i = 0; i < numlevelflats; i++) { lump = levelflats[i].lumpnum; if (devparm) - flatmemory += W_LumpLength(lump); + flatmem += W_LumpLength(lump); R_GetFlat(lump); } - return flatmemory; + + return flatmem; } // help function for P_LoadSectors, find a flat in the active wad files, diff --git a/src/w_wad.c b/src/w_wad.c index aa90fa9f3..c4b134ec7 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -148,7 +148,7 @@ static char filenamebuf[MAX_WADPATH]; #include // Windows can't open utf-8 path so it must be converted to utf-16 -FILE* fopen_utf8(const char* filename, const char* mode) +static FILE* fopen_utf8(const char* filename, const char* mode) { static const int MY_PATH_MAX = 2048; WCHAR nameW[MY_PATH_MAX];