fix all remaining compiler issues

Checked with GCC 9.2.0 (MinGW-W32) under MSYS2 with
-O2 -g -Wall -Wdeclaration-after-statement -Wredundant-decls
This commit is contained in:
Fabian Greffrath 2020-01-08 08:59:21 +01:00
parent 3be0782240
commit 0d5ae9b1ad
18 changed files with 49 additions and 63 deletions

View File

@ -686,7 +686,6 @@ boolean AM_Responder
( event_t* ev )
{
int rc;
static int cheatstate=0;
static int bigstate=0;
static char buffer[20];
int ch; // phares
@ -780,7 +779,6 @@ boolean AM_Responder
} // |
else // phares
{
cheatstate=0;
rc = false;
}
}

View File

@ -1535,7 +1535,7 @@ void ProcessDehFile(char *filename, char *outfilename, int lumpnum)
void deh_procBexCodePointers(DEHFILE *fpin, FILE* fpout, char *line)
{
char key[DEH_MAXKEYLEN];
char inbuffer[DEH_BUFFERMAX];
char inbuffer[DEH_BUFFERMAX+1];
int indexnum;
char mnemonic[DEH_MAXKEYLEN]; // to hold the codepointer mnemonic
int i; // looper
@ -1611,7 +1611,7 @@ void deh_procBexCodePointers(DEHFILE *fpin, FILE* fpout, char *line)
void deh_procThing(DEHFILE *fpin, FILE* fpout, char *line)
{
char key[DEH_MAXKEYLEN];
char inbuffer[DEH_BUFFERMAX];
char inbuffer[DEH_BUFFERMAX+1];
long value; // All deh values are ints or longs
int indexnum;
int ix;
@ -1703,7 +1703,7 @@ void deh_procThing(DEHFILE *fpin, FILE* fpout, char *line)
void deh_procFrame(DEHFILE *fpin, FILE* fpout, char *line)
{
char key[DEH_MAXKEYLEN];
char inbuffer[DEH_BUFFERMAX];
char inbuffer[DEH_BUFFERMAX+1];
long value; // All deh values are ints or longs
int indexnum;
@ -1783,7 +1783,7 @@ void deh_procFrame(DEHFILE *fpin, FILE* fpout, char *line)
void deh_procPointer(DEHFILE *fpin, FILE* fpout, char *line) // done
{
char key[DEH_MAXKEYLEN];
char inbuffer[DEH_BUFFERMAX];
char inbuffer[DEH_BUFFERMAX+1];
long value; // All deh values are ints or longs
int indexnum;
int i; // looper
@ -1857,7 +1857,7 @@ void deh_procPointer(DEHFILE *fpin, FILE* fpout, char *line) // done
void deh_procSounds(DEHFILE *fpin, FILE* fpout, char *line)
{
char key[DEH_MAXKEYLEN];
char inbuffer[DEH_BUFFERMAX];
char inbuffer[DEH_BUFFERMAX+1];
long value; // All deh values are ints or longs
int indexnum;
@ -1925,7 +1925,7 @@ void deh_procSounds(DEHFILE *fpin, FILE* fpout, char *line)
void deh_procAmmo(DEHFILE *fpin, FILE* fpout, char *line)
{
char key[DEH_MAXKEYLEN];
char inbuffer[DEH_BUFFERMAX];
char inbuffer[DEH_BUFFERMAX+1];
long value; // All deh values are ints or longs
int indexnum;
@ -1971,7 +1971,7 @@ void deh_procAmmo(DEHFILE *fpin, FILE* fpout, char *line)
void deh_procWeapon(DEHFILE *fpin, FILE* fpout, char *line)
{
char key[DEH_MAXKEYLEN];
char inbuffer[DEH_BUFFERMAX];
char inbuffer[DEH_BUFFERMAX+1];
long value; // All deh values are ints or longs
int indexnum;
@ -2029,7 +2029,7 @@ void deh_procWeapon(DEHFILE *fpin, FILE* fpout, char *line)
void deh_procSprite(DEHFILE *fpin, FILE* fpout, char *line) // Not supported
{
char key[DEH_MAXKEYLEN];
char inbuffer[DEH_BUFFERMAX];
char inbuffer[DEH_BUFFERMAX+1];
int indexnum;
// Too little is known about what this is supposed to do, and
@ -2063,7 +2063,7 @@ void deh_procSprite(DEHFILE *fpin, FILE* fpout, char *line) // Not supported
void deh_procPars(DEHFILE *fpin, FILE* fpout, char *line) // extension
{
char key[DEH_MAXKEYLEN];
char inbuffer[DEH_BUFFERMAX];
char inbuffer[DEH_BUFFERMAX+1];
int indexnum;
int episode, level, partime, oldpar;
@ -2149,7 +2149,7 @@ void deh_procPars(DEHFILE *fpin, FILE* fpout, char *line) // extension
void deh_procCheat(DEHFILE *fpin, FILE* fpout, char *line) // done
{
char key[DEH_MAXKEYLEN];
char inbuffer[DEH_BUFFERMAX];
char inbuffer[DEH_BUFFERMAX+1];
long value; // All deh values are ints or longs
char *strval = ""; // pointer to the value area
int ix, iy; // array indices
@ -2223,7 +2223,7 @@ void deh_procCheat(DEHFILE *fpin, FILE* fpout, char *line) // done
void deh_procMisc(DEHFILE *fpin, FILE* fpout, char *line) // done
{
char key[DEH_MAXKEYLEN];
char inbuffer[DEH_BUFFERMAX];
char inbuffer[DEH_BUFFERMAX+1];
long value; // All deh values are ints or longs
strncpy(inbuffer,line,DEH_BUFFERMAX);
@ -2430,7 +2430,7 @@ void deh_procText(DEHFILE *fpin, FILE* fpout, char *line)
void deh_procError(DEHFILE *fpin, FILE* fpout, char *line)
{
char inbuffer[DEH_BUFFERMAX];
char inbuffer[DEH_BUFFERMAX+1];
strncpy(inbuffer,line,DEH_BUFFERMAX);
if (fpout) fprintf(fpout,"Unmatched Block: '%s'\n",inbuffer);
@ -2448,7 +2448,7 @@ void deh_procError(DEHFILE *fpin, FILE* fpout, char *line)
void deh_procStrings(DEHFILE *fpin, FILE* fpout, char *line)
{
char key[DEH_MAXKEYLEN];
char inbuffer[DEH_BUFFERMAX];
char inbuffer[DEH_BUFFERMAX+1];
long value; // All deh values are ints or longs
char *strval; // holds the string value of the line
static int maxstrlen = 128; // maximum string length, bumped 128 at

View File

@ -459,7 +459,7 @@ void CheckAbort (void)
I_StartTic ();
I_StartTic ();
for ( ; eventtail != eventhead ; eventtail = (++eventtail)&(MAXEVENTS-1) )
for ( ; eventtail != eventhead ; eventtail = (eventtail+1)&(MAXEVENTS-1) )
{
ev = &events[eventtail];
if (ev->type == ev_keydown && ev->data1 == key_escape) // phares
@ -504,7 +504,7 @@ void D_ArbitrateNetStart (void)
// killough 11/98: NOTE: this code produces no inconsistency errors.
// However, TeamTNT's code =does= produce inconsistencies. Go figur.
G_ReadOptions((char *) netbuffer->cmds);
G_ReadOptions((byte *) netbuffer->cmds);
// killough 12/98: removed obsolete compatibility flag and
// removed printf()'s, since there are too many options to
@ -544,7 +544,7 @@ void D_ArbitrateNetStart (void)
I_Error("D_ArbitrateNetStart: GAME_OPTION_SIZE"
" too large w.r.t. BACKUPTICS");
G_WriteOptions((char *) netbuffer->cmds); // killough 12/98
G_WriteOptions((byte *) netbuffer->cmds); // killough 12/98
// killough 5/2/98: Always write the maximum number of tics.
netbuffer->numtics = BACKUPTICS;

View File

@ -689,8 +689,8 @@ static void G_DoLoadLevel(void)
joyxmove = joyymove = 0;
mousex = mousey = 0;
sendpause = sendsave = paused = false;
memset (mousebuttons, 0, sizeof(mousebuttons));
memset (joybuttons, 0, sizeof(joybuttons));
memset (mousearray, 0, sizeof(mousearray));
memset (joyarray, 0, sizeof(joyarray));
//jff 4/26/98 wake up the status bar in case were coming out of a DM demo
// killough 5/13/98: in case netdemo has consoleplayer other than green
@ -808,7 +808,9 @@ boolean G_Responder(event_t* ev)
}
if (gamestate == GS_FINALE && F_Responder(ev))
{
return true; // finale ate the event
}
// If the next/previous weapon keys are pressed, set the next_weapon
// variable to change weapons when the next ticcmd is generated.
@ -1384,9 +1386,9 @@ static void G_DoSaveGame(void)
for (*save_p = 0; *w; w++)
{
CheckSaveGame(strlen(*w)+2);
strcat(strcat(save_p, *w), "\n");
strcat(strcat((char *) save_p, *w), "\n");
}
save_p += strlen(save_p)+1;
save_p += strlen((char *) save_p)+1;
}
CheckSaveGame(GAME_OPTION_SIZE+MIN_MAXPLAYERS+10);
@ -1440,13 +1442,12 @@ static void G_DoSaveGame(void)
static void G_DoLoadGame(void)
{
int length, i;
int i;
char vcheck[VERSIONSIZE];
ULong64 checksum;
gameaction = ga_nothing;
length = M_ReadFile(savename, &savebuffer);
save_p = savebuffer + SAVESTRINGSIZE;
// skip the description field
@ -1455,7 +1456,7 @@ static void G_DoLoadGame(void)
sprintf (vcheck,VERSIONID,MBFVERSION);
// killough 2/22/98: Friendly savegame version difference message
if (!forced_loadgame && strncmp(save_p, vcheck, VERSIONSIZE))
if (!forced_loadgame && strncmp((char *) save_p, vcheck, VERSIONSIZE))
{
G_LoadGameErr("Different Savegame Version!!!\n\nAre you sure?");
return;
@ -1476,10 +1477,10 @@ static void G_DoLoadGame(void)
checksum = G_Signature();
if (memcmp(&checksum, save_p, sizeof checksum))
{
char *msg = malloc(strlen(save_p + sizeof checksum) + 128);
char *msg = malloc(strlen((char *) save_p + sizeof checksum) + 128);
strcpy(msg,"Incompatible Savegame!!!\n");
if (save_p[sizeof checksum])
strcat(strcat(msg,"Wads expected:\n\n"), save_p + sizeof checksum);
strcat(strcat(msg,"Wads expected:\n\n"), (char *) save_p + sizeof checksum);
strcat(msg, "\nAre you sure?");
G_LoadGameErr(msg);
free(msg);

View File

@ -105,7 +105,6 @@ int (*I_GetTime)() = I_GetTime_Error; // killough
int mousepresent;
int joystickpresent; // phares 4/3/98
static int orig_key_shifts; // killough 3/6/98: original keyboard shift state
int leds_always_off; // Tells it not to update LEDs
// haleyjd: SDL joystick support

View File

@ -83,8 +83,6 @@ void I_JoystickEvents(void)
int joy_b1, joy_b2, joy_b3, joy_b4;
int joy_b5, joy_b6, joy_b7, joy_b8;
Sint16 joy_x, joy_y;
static int old_joy_b1, old_joy_b2, old_joy_b3, old_joy_b4;
static int old_joy_b5, old_joy_b6, old_joy_b7, old_joy_b8;
if(!joystickpresent || !usejoystick || !sdlJoystick)
return;
@ -468,8 +466,6 @@ static void I_HandleKeyboardEvent(SDL_Event *sdlevent)
static void HandleWindowEvent(SDL_WindowEvent *event)
{
int i;
switch (event->event)
{
// Don't render the screen when the window is minimized:
@ -680,10 +676,7 @@ int hires;
boolean noblit;
static int in_graphics_mode;
static int in_page_flip, in_hires, linear;
static int scroll_offset;
static unsigned long screen_base_addr;
static unsigned destscreen;
static int in_page_flip, in_hires;
void I_FinishUpdate(void)
{
@ -849,6 +842,8 @@ boolean I_WritePNGfile(char *filename)
{
#ifdef HAVE_SDL_IMAGE
return IMG_SavePNG(sdlscreen, filename) == 0;
#else
return false;
#endif
}

View File

@ -715,7 +715,7 @@ boolean M_FindCheats(int key)
for (i=0;cheat[i].cheat;i++)
{
ULong64 c=0, m=0;
const unsigned char *p;
const char *p;
for (p=cheat[i].cheat; *p; p++)
{
unsigned key = tolower(*p)-'a'; // convert to 0-31

View File

@ -34,7 +34,7 @@
// killough 4/16/98: Cheat table structure
extern struct cheat_s {
const unsigned char *cheat;
const char *cheat;
const char *const deh_cheat;
enum {
always = 0,

View File

@ -1869,7 +1869,7 @@ void M_DrawSetting(setup_menu_t* s)
strcpy(menu_buffer, gather_buffer);
}
else
sprintf(menu_buffer,"%d",*s->var.def->location);
sprintf(menu_buffer,"%d",s->var.def->location->i);
M_DrawMenuString(x,y,color);
return;
}
@ -1927,7 +1927,7 @@ void M_DrawSetting(setup_menu_t* s)
if (flags & (S_WEAP|S_CRITEM)) // weapon number or color range
{
sprintf(menu_buffer,"%d", *s->var.def->location);
sprintf(menu_buffer,"%d", s->var.def->location->i);
M_DrawMenuString(x,y, flags & S_CRITEM ? s->var.def->location->i : color);
return;
}
@ -1937,7 +1937,7 @@ void M_DrawSetting(setup_menu_t* s)
if (flags & S_COLOR) // Automap paint chip
{
int i, ch;
char *ptr = colorblock;
byte *ptr = colorblock;
// draw the border of the paint chip

View File

@ -1847,12 +1847,12 @@ void M_SaveDefaults (void)
fprintf(f,"[(\"%s\")]", (char *) dp->defaultvalue.s) :
dp->limit.min == UL ?
dp->limit.max == UL ?
fprintf(f, "[?-?(%d)]", dp->defaultvalue) :
fprintf(f, "[?-%d(%d)]", dp->limit.max, dp->defaultvalue) :
fprintf(f, "[?-?(%d)]", dp->defaultvalue.i) :
fprintf(f, "[?-%d(%d)]", dp->limit.max, dp->defaultvalue.i) :
dp->limit.max == UL ?
fprintf(f, "[%d-?(%d)]", dp->limit.min, dp->defaultvalue) :
fprintf(f, "[%d-?(%d)]", dp->limit.min, dp->defaultvalue.i) :
fprintf(f, "[%d-%d(%d)]", dp->limit.min, dp->limit.max,
dp->defaultvalue)) == EOF ||
dp->defaultvalue.i)) == EOF ||
fprintf(f," %s %s\n", dp->help, dp->wad_allowed ? "*" :"") == EOF)
goto error;

View File

@ -601,6 +601,7 @@ int MidiToMIDI(UBYTE *mid,MIDI *mididata)
return 0;
}
#if 0
//#ifdef STANDALONE /* this code unused by BOOM provided for future portability */
// /* it also provides a MUS to MID file converter*/
// proff: I moved this down, because I need MIDItoMidi
@ -627,6 +628,7 @@ static void FreeTracks(MIDI *mididata)
mididata->track[i].len = 0;
}
}
#endif
//
// TWriteLength()

View File

@ -390,7 +390,6 @@ int EV_DoDoor(line_t *line, vldoor_e type)
int EV_VerticalDoor(line_t *line, mobj_t *thing)
{
player_t* player;
int secnum;
sector_t* sec;
vldoor_t* door;
@ -448,7 +447,6 @@ int EV_VerticalDoor(line_t *line, mobj_t *thing)
// get the sector on the second side of activating linedef
sec = sides[line->sidenum[1]].sector;
secnum = sec-sectors;
// if door already has a thinker, use it
if (sec->ceilingdata) //jff 2/22/98

View File

@ -853,7 +853,7 @@ int EV_DoDonut(line_t* line)
//jff 3/29/98 use true two-sidedness, not the flag
if (comp[comp_model])
{
if ((!s2->lines[i]->flags & ML_TWOSIDED) ||
if ((!(s2->lines[i]->flags & ML_TWOSIDED)) ||
(s2->lines[i]->backsector == s1))
continue;
}

View File

@ -129,8 +129,10 @@ boolean P_GiveAmmo(player_t *player, ammotype_t ammo, int num)
case am_shell:
if (player->readyweapon == wp_fist || player->readyweapon == wp_pistol)
{
if (player->weaponowned[wp_shotgun])
player->pendingweapon = wp_shotgun;
}
break;
case am_cell:

View File

@ -2269,11 +2269,6 @@ void P_SpawnSpecials (void)
{
sector_t* sector;
int i;
int episode;
episode = 1;
if (W_CheckNumForName("texture2") >= 0)
episode = 2;
// See if -timer needs to be used.
levelTimer = false;

View File

@ -508,7 +508,7 @@ void R_RenderPlayerView (player_t* player)
if (autodetect_hom)
{ // killough 2/10/98: add flashing red HOM indicators
char c[47*47];
byte c[47*47];
extern int lastshottic;
int i , color = !flashing_hom || (gametic % 20) < 9 ? 0xb0 : 0;
memset(*screens+viewwindowy*linesize,color,viewheight*linesize);

View File

@ -238,7 +238,7 @@ static void W_CoalesceMarkedResource(const char *start_marker,
{ // If this is the first start marker, add start marker to marked lumps
if (!num_marked)
{
strncpy(marked->name, start_marker, 8);
memcpy(marked->name, start_marker, 8);
marked->size = 0; // killough 3/20/98: force size to be 0
marked->namespace = ns_global; // killough 4/17/98
num_marked = 1;
@ -271,7 +271,7 @@ static void W_CoalesceMarkedResource(const char *start_marker,
{
lumpinfo[numlumps].size = 0; // killough 3/20/98: force size to be 0
lumpinfo[numlumps].namespace = ns_global; // killough 4/17/98
strncpy(lumpinfo[numlumps++].name, end_marker, 8);
memcpy(lumpinfo[numlumps++].name, end_marker, 8);
}
}
@ -535,7 +535,7 @@ void WritePredefinedLumpWad(const char *filename)
fileinfo.filepos = LONG(filepos);
fileinfo.size = LONG(predefined_lumps[i].size);
strncpy(fileinfo.name, predefined_lumps[i].name, 8);
memcpy(fileinfo.name, predefined_lumps[i].name, 8);
fwrite(&fileinfo, 1, sizeof(fileinfo), file);

View File

@ -1160,10 +1160,6 @@ static void WI_drawDeathmatchStats(void)
int y;
int w;
int lh; // line height
lh = WI_SPACINGY;
WI_slamBackground();
// draw animated background
@ -1837,7 +1833,7 @@ static void WI_loadData(void)
PU_STATIC, 0);
for (i=0 ; i<NUMCMAPS ; i++)
{
sprintf(name, "CWILV%2.2d", i);
snprintf(name, sizeof(name), "CWILV%2.2d", i);
lnames[i] = W_CacheLumpName(name, PU_STATIC);
}
}
@ -1871,7 +1867,7 @@ static void WI_loadData(void)
if (wbs->epsd != 1 || j != 8)
{
// animations
sprintf(name, "WIA%d%.2d%.2d", wbs->epsd, j, i);
snprintf(name, sizeof(name), "WIA%d%.2d%.2d", wbs->epsd, j, i);
a->p[i] = W_CacheLumpName(name, PU_STATIC);
}
else