From a9ef21aa509e1e0dbec131cb8cb5c72183882ac5 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Fri, 1 Mar 2024 19:35:04 +0000 Subject: [PATCH 1/2] Clang: clean up conditional-uninitialized warnings --- src/CMakeLists.txt | 6 ++++++ src/blua/lvm.c | 2 +- src/g_demo.c | 2 +- src/g_game.c | 2 +- src/netcode/d_net.c | 2 +- src/p_user.c | 4 ++-- src/sdl/i_system.c | 2 +- src/st_stuff.c | 2 +- 8 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1bdfc94f5..153a1629e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -245,6 +245,7 @@ target_compile_options(SRB2SDL2 PRIVATE # This is a direct translation from versions.mk $<$,$>: -Wall + -Wextra -Wno-trigraphs -W # Was controlled by RELAXWARNINGS -Wfloat-equal @@ -329,7 +330,9 @@ target_compile_options(SRB2SDL2 PRIVATE $<$,$,$>>: -Wall -Wno-absolute-value + -Wextra -Wno-trigraphs + -Wconditional-uninitialized -Wno-error=non-literal-null-conversion -Wno-error=constant-conversion -Wno-error=unused-but-set-variable @@ -346,6 +349,9 @@ target_compile_options(SRB2SDL2 PRIVATE # C++, GNU, Clang and Apple Clang $<$,$,$,$>>: -Wall + -Wextra + -Wno-trigraphs + -Wconditional-uninitialized > # C++, MSVC diff --git a/src/blua/lvm.c b/src/blua/lvm.c index b74fef4ee..627685b38 100644 --- a/src/blua/lvm.c +++ b/src/blua/lvm.c @@ -134,7 +134,7 @@ void luaV_gettable (lua_State *L, TValue *t, TValue *key, StkId val) { void luaV_settable (lua_State *L, TValue *t, TValue *key, StkId val) { int loop; for (loop = 0; loop < MAXTAGLOOP; loop++) { - TValue *tm; + TValue *tm = NULL; if (ttistable(t)) { /* `t' is a table? */ Table *h = hvalue(t); TValue *oldval = luaH_set(L, h, key); /* do a primitive set */ diff --git a/src/g_demo.c b/src/g_demo.c index f64f34168..859ac5cba 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -1650,7 +1650,7 @@ static void G_LoadDemoExtraFiles(UINT8 **pp, UINT16 this_demo_version) UINT16 totalfiles; char filename[MAX_WADPATH]; UINT8 md5sum[16]; - filestatus_t ncs; + filestatus_t ncs = FS_NOTFOUND; boolean toomany = false; boolean alreadyloaded; UINT16 i, j; diff --git a/src/g_game.c b/src/g_game.c index 6a99381e7..0e7e2b344 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -5403,7 +5403,7 @@ void G_FreeMapSearch(mapsearchfreq_t *freq, INT32 freqc) INT32 G_FindMapByNameOrCode(const char *mapname, char **realmapnamep) { boolean usemapcode = false; - INT32 newmapnum; + INT32 newmapnum = -1; size_t mapnamelen = strlen(mapname); char *p; diff --git a/src/netcode/d_net.c b/src/netcode/d_net.c index 5a2e229d3..b24409db1 100644 --- a/src/netcode/d_net.c +++ b/src/netcode/d_net.c @@ -940,7 +940,7 @@ void Command_Droprate(void) static boolean ShouldDropPacket(void) { return (packetdropquantity[netbuffer->packettype]) - || (packetdroprate != 0 && rand() < (RAND_MAX * (packetdroprate / 100.f))) || packetdroprate == 100; + || (packetdroprate != 0 && rand() < (((double)RAND_MAX) * (packetdroprate / 100.f))) || packetdroprate == 100; } #endif diff --git a/src/p_user.c b/src/p_user.c index 49b4b2c94..9fc1f8c9b 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -11307,7 +11307,7 @@ void P_DoTailsOverlay(player_t *player, mobj_t *tails) fixed_t backwards = -1*FRACUNIT; boolean doswim = (player->panim == PA_ABILITY && (player->mo->eflags & MFE_UNDERWATER)); boolean doroll = (player->panim == PA_ROLL || (player->panim == PA_JUMP && !(player->charflags & SF_NOJUMPSPIN)) || doswim); - angle_t rollangle; + angle_t rollangle = 0; boolean panimchange; INT32 ticnum = 0; statenum_t chosenstate; @@ -12089,7 +12089,7 @@ void P_PlayerThink(player_t *player) // deez New User eXperiences. { angle_t oldang = player->drawangle, diff = 0; - UINT8 factor; + UINT8 factor = 0; // Directionchar! // Camera angle stuff. if (player->exiting // no control, no modification diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 173866e8b..97e77aa90 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -2857,7 +2857,7 @@ size_t I_GetRandomBytes(char *destination, size_t count) { #if defined (__unix__) || defined (UNIXCOMMON) || defined(__APPLE__) FILE *rndsource; - size_t actual_bytes; + size_t actual_bytes = 0; if (!(rndsource = fopen("/dev/urandom", "r"))) if (!(rndsource = fopen("/dev/random", "r"))) diff --git a/src/st_stuff.c b/src/st_stuff.c index 342c7dcd8..b3e392499 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -815,7 +815,7 @@ static inline void ST_drawRings(void) static void ST_drawLivesArea(void) { - INT32 v_colmap = V_YELLOWMAP, livescount; + INT32 v_colmap = V_YELLOWMAP, livescount = -1; boolean notgreyedout = false; if (!stplyr->skincolor) From e0819b5a25ac7961a6096f9e2e692302a77810c3 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Fri, 1 Mar 2024 20:49:59 +0000 Subject: [PATCH 2/2] Add printf formating --- src/hardware/r_opengl/r_opengl.c | 4 ++-- src/netcode/http-mserv.c | 2 +- src/r_translation.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index acd09f614..75a92c2fb 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -180,7 +180,7 @@ FUNCPRINTF void GL_DBG_Printf(const char *format, ...) // GL_MSG_Warning : Raises a warning. // -----------------+ -static void GL_MSG_Warning(const char *format, ...) +FUNCPRINTF static void GL_MSG_Warning(const char *format, ...) { char str[4096] = ""; va_list arglist; @@ -203,7 +203,7 @@ static void GL_MSG_Warning(const char *format, ...) // GL_MSG_Error : Raises an error. // -----------------+ -static void GL_MSG_Error(const char *format, ...) +FUNCPRINTF static void GL_MSG_Error(const char *format, ...) { char str[4096] = ""; va_list arglist; diff --git a/src/netcode/http-mserv.c b/src/netcode/http-mserv.c index 2b52380cf..b8c662a51 100644 --- a/src/netcode/http-mserv.c +++ b/src/netcode/http-mserv.c @@ -134,7 +134,7 @@ HMS_on_read (char *s, size_t _1, size_t n, void *userdata) return n; } -static struct HMS_buffer * +FUNCDEBUG static struct HMS_buffer * HMS_connect (int proto, const char *format, ...) { va_list ap; diff --git a/src/r_translation.c b/src/r_translation.c index 390545802..a53b30e9f 100644 --- a/src/r_translation.c +++ b/src/r_translation.c @@ -556,7 +556,7 @@ static boolean ParseDecimal(tokenizer_t *sc, double *out) return M_StringToDecimal(tkn, out); } -static struct PaletteRemapParseResult *ThrowError(const char *format, ...) +FUNCPRINTF static struct PaletteRemapParseResult *ThrowError(const char *format, ...) { const size_t err_size = 512 * sizeof(char); @@ -792,7 +792,7 @@ static struct PaletteRemapParseResult *PaletteRemap_ParseTranslation(const char return result; } -static void PrintError(const char *name, const char *format, ...) +FUNCDEBUG static void PrintError(const char *name, const char *format, ...) { char error[256];