From 2e8f6da6fdf0eb71e58d2cdaad24e5b0a332f675 Mon Sep 17 00:00:00 2001 From: Fabian Greffrath Date: Fri, 8 May 2015 08:43:19 +0200 Subject: warnings: fix ".. may be used uninitialized in this function" warnings Actually, it was already impossible for the reported variables to be used uninitialized, because they were all assigned a value by calling ReadByte() and the function would return if that failed. However, the compiler couldn't know about this fact, so we do him the favor and initialized them to 0. --- src/midifile.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/midifile.c b/src/midifile.c index 92ffd803..1ab4ecdb 100644 --- a/src/midifile.c +++ b/src/midifile.c @@ -130,7 +130,7 @@ static boolean ReadByte(byte *result, FILE *stream) static boolean ReadVariableLength(unsigned int *result, FILE *stream) { int i; - byte b; + byte b = 0; *result = 0; @@ -203,7 +203,7 @@ static boolean ReadChannelEvent(midi_event_t *event, byte event_type, boolean two_param, FILE *stream) { - byte b; + byte b = 0; // Set basics: @@ -269,7 +269,7 @@ static boolean ReadSysExEvent(midi_event_t *event, int event_type, static boolean ReadMetaEvent(midi_event_t *event, FILE *stream) { - byte b; + byte b = 0; event->event_type = MIDI_EVENT_META; @@ -308,7 +308,7 @@ static boolean ReadMetaEvent(midi_event_t *event, FILE *stream) static boolean ReadEvent(midi_event_t *event, unsigned int *last_event_type, FILE *stream) { - byte event_type; + byte event_type = 0; if (!ReadVariableLength(&event->delta_time, stream)) { -- cgit v1.2.3 From 744697c4fe213821c18dd882098b311550d42da7 Mon Sep 17 00:00:00 2001 From: Fabian Greffrath Date: Fri, 8 May 2015 08:57:20 +0200 Subject: warnings: fix "iteration XY invokes undefined behavior" warnings These were caused by loops which caused overflow of variables of type angle_t (= unsigned) by multiplication with iterators of typed int in angle calculations. Changing the type of the iterator variables to "unsigned int" prevents the undefined behavior. --- src/heretic/p_enemy.c | 4 ++-- src/heretic/p_pspr.c | 2 +- src/hexen/p_enemy.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/heretic/p_enemy.c b/src/heretic/p_enemy.c index b4222ec8..55608c54 100644 --- a/src/heretic/p_enemy.c +++ b/src/heretic/p_enemy.c @@ -1904,7 +1904,7 @@ void A_WhirlwindSeek(mobj_t * actor) void A_HeadIceImpact(mobj_t * ice) { - int i; + unsigned int i; angle_t angle; mobj_t *shard; @@ -2519,7 +2519,7 @@ void A_VolcanoBlast(mobj_t * volcano) void A_VolcBallImpact(mobj_t * ball) { - int i; + unsigned int i; mobj_t *tiny; angle_t angle; diff --git a/src/heretic/p_pspr.c b/src/heretic/p_pspr.c index 2cbe3674..813dd6a2 100644 --- a/src/heretic/p_pspr.c +++ b/src/heretic/p_pspr.c @@ -1330,7 +1330,7 @@ void A_DeathBallImpact(mobj_t * ball) void A_SpawnRippers(mobj_t * actor) { - int i; + unsigned int i; angle_t angle; mobj_t *ripper; diff --git a/src/hexen/p_enemy.c b/src/hexen/p_enemy.c index dc2c9fe5..38f3a2b5 100644 --- a/src/hexen/p_enemy.c +++ b/src/hexen/p_enemy.c @@ -3855,7 +3855,7 @@ void A_IceGuyDie(mobj_t * actor) void A_IceGuyMissileExplode(mobj_t * actor) { mobj_t *mo; - int i; + unsigned int i; for (i = 0; i < 8; i++) { -- cgit v1.2.3 From 5b423fcfc1ba0774b10c566a63b9e14c3c02409c Mon Sep 17 00:00:00 2001 From: Fabian Greffrath Date: Fri, 8 May 2015 09:05:11 +0200 Subject: warnings: fix "redundant redeclaration of ‘player_names’" The "extern char player_names[8][16]" array is already declared in hu_stuff.h:59. --- src/strife/g_game.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/strife/g_game.c b/src/strife/g_game.c index e0c0ae27..906d3c99 100644 --- a/src/strife/g_game.c +++ b/src/strife/g_game.c @@ -984,7 +984,6 @@ void G_Ticker (void) && turbodetected[i]) { static char turbomessage[80]; - extern char player_names[8][16]; M_snprintf(turbomessage, sizeof(turbomessage), "%s is turbo!", player_names[i]); players[consoleplayer].message = turbomessage; -- cgit v1.2.3 From f1050ee4fead9f47471f25dc10650dad3bf68220 Mon Sep 17 00:00:00 2001 From: Fabian Greffrath Date: Fri, 8 May 2015 09:11:23 +0200 Subject: warnings: fix "variable ‘..’ set but not used" warnings Fixed by commenting out the reported variables and their settings instead of removing them. Since I am not sure if they were added by mistake or by purpose and then overseen, I think it's better to keep them in the code but not compile them in for now. --- src/i_sdlmusic.c | 4 ++-- src/i_sdlsound.c | 4 ++-- src/strife/f_finale.c | 8 ++++---- src/strife/p_setup.c | 4 ++-- src/strife/st_stuff.c | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/i_sdlmusic.c b/src/i_sdlmusic.c index 6acb528f..80bc49ab 100644 --- a/src/i_sdlmusic.c +++ b/src/i_sdlmusic.c @@ -633,7 +633,7 @@ static boolean ReadSubstituteConfig(char *filename) FILE *fs; char *error; int linenum = 1; - int old_subst_music_len; +// int old_subst_music_len; fs = fopen(filename, "r"); @@ -642,7 +642,7 @@ static boolean ReadSubstituteConfig(char *filename) return false; } - old_subst_music_len = subst_music_len; +// old_subst_music_len = subst_music_len; while (!feof(fs)) { diff --git a/src/i_sdlsound.c b/src/i_sdlsound.c index 7089378e..79a15dbf 100644 --- a/src/i_sdlsound.c +++ b/src/i_sdlsound.c @@ -340,7 +340,7 @@ static boolean ExpandSoundData_SRC(sfxinfo_t *sfxinfo, { SRC_DATA src_data; uint32_t i, abuf_index=0, clipped=0; - uint32_t alen; +// uint32_t alen; int retn; int16_t *expanded; Mix_Chunk *chunk; @@ -372,7 +372,7 @@ static boolean ExpandSoundData_SRC(sfxinfo_t *sfxinfo, // Allocate the new chunk. - alen = src_data.output_frames_gen * 4; +// alen = src_data.output_frames_gen * 4; chunk = AllocateSound(sfxinfo, src_data.output_frames_gen * 4); diff --git a/src/strife/f_finale.c b/src/strife/f_finale.c index 9c55c102..23ed3dec 100644 --- a/src/strife/f_finale.c +++ b/src/strife/f_finale.c @@ -934,11 +934,11 @@ void F_DrawMap34End (void) { signed int scrolled; int x; - patch_t* p1; - patch_t* p2; +// patch_t* p1; +// patch_t* p2; - p1 = W_CacheLumpName (DEH_String("credit"), PU_LEVEL); - p2 = W_CacheLumpName (DEH_String("vellogo"), PU_LEVEL); +// p1 = W_CacheLumpName (DEH_String("credit"), PU_LEVEL); +// p2 = W_CacheLumpName (DEH_String("vellogo"), PU_LEVEL); V_MarkRect (0, 0, SCREENWIDTH, SCREENHEIGHT); diff --git a/src/strife/p_setup.c b/src/strife/p_setup.c index 1fd889fa..a8c025d4 100644 --- a/src/strife/p_setup.c +++ b/src/strife/p_setup.c @@ -324,7 +324,7 @@ void P_LoadThings (int lump) mapthing_t *mt; mapthing_t spawnthing; int numthings; - boolean spawn; +// boolean spawn; data = W_CacheLumpNum (lump,PU_STATIC); numthings = W_LumpLength (lump) / sizeof(mapthing_t); @@ -332,7 +332,7 @@ void P_LoadThings (int lump) mt = (mapthing_t *)data; for (i=0 ; i