Address some longstanding warnings with printf when building with MinGW's GCC 6 and newer.

Building with said newer versions may fix the -Wodr warning when building for release.

git-svn-id: https://svn.eduke32.com/eduke32@6140 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2017-06-05 10:05:12 +00:00
parent 914762513d
commit f781f21ccd
7 changed files with 53 additions and 57 deletions

View file

@ -356,7 +356,7 @@ int32_t scriptfile_getsymbolvalue(char const *name, int32_t *val)
sscanf(name + 2, "%" PRIx64 "", &x); sscanf(name + 2, "%" PRIx64 "", &x);
if (EDUKE32_PREDICT_FALSE(x > UINT32_MAX)) if (EDUKE32_PREDICT_FALSE(x > UINT32_MAX))
initprintf("warning: number 0x%" PRIx64 " truncated to 32 bits.\n", x); buildprint("warning: number 0x", hex(x), " truncated to 32 bits.\n");
*val = x; *val = x;
return 1; return 1;

View file

@ -1175,40 +1175,39 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio)
void G_DumpDebugInfo(void) void G_DumpDebugInfo(void)
{ {
#if !defined LUNATIC #if !defined LUNATIC
static char const s_WEAPON[] = "WEAPON";
int32_t i,j,x; int32_t i,j,x;
// FILE * fp=fopen("condebug.log","w"); // FILE * fp=fopen("condebug.log","w");
VM_ScriptInfo(insptr, 64); VM_ScriptInfo(insptr, 64);
OSD_Printf("\n"); buildprint("\nCurrent gamevar values:\n");
OSD_Printf("Current gamevar values:\n");
for (i=0; i<MAX_WEAPONS; i++) for (i=0; i<MAX_WEAPONS; i++)
{ {
for (j=0; j<numplayers; j++) for (j=0; j<numplayers; j++)
{ {
OSD_Printf("Player %d\n\n",j); buildprint("Player ", j, "\n\n");
OSD_Printf("WEAPON%d_CLIP %" PRIdPTR "\n", i, PWEAPON(j, i, Clip)); buildprint(s_WEAPON, i, "_CLIP ", PWEAPON(j, i, Clip), "\n");
OSD_Printf("WEAPON%d_RELOAD %" PRIdPTR "\n", i, PWEAPON(j, i, Reload)); buildprint(s_WEAPON, i, "_RELOAD ", PWEAPON(j, i, Reload), "\n");
OSD_Printf("WEAPON%d_FIREDELAY %" PRIdPTR "\n", i, PWEAPON(j, i, FireDelay)); buildprint(s_WEAPON, i, "_FIREDELAY ", PWEAPON(j, i, FireDelay), "\n");
OSD_Printf("WEAPON%d_TOTALTIME %" PRIdPTR "\n", i, PWEAPON(j, i, TotalTime)); buildprint(s_WEAPON, i, "_TOTALTIME ", PWEAPON(j, i, TotalTime), "\n");
OSD_Printf("WEAPON%d_HOLDDELAY %" PRIdPTR "\n", i, PWEAPON(j, i, HoldDelay)); buildprint(s_WEAPON, i, "_HOLDDELAY ", PWEAPON(j, i, HoldDelay), "\n");
OSD_Printf("WEAPON%d_FLAGS %" PRIdPTR "\n", i, PWEAPON(j, i, Flags)); buildprint(s_WEAPON, i, "_FLAGS ", PWEAPON(j, i, Flags), "\n");
OSD_Printf("WEAPON%d_SHOOTS %" PRIdPTR "\n", i, PWEAPON(j, i, Shoots)); buildprint(s_WEAPON, i, "_SHOOTS ", PWEAPON(j, i, Shoots), "\n");
OSD_Printf("WEAPON%d_SPAWNTIME %" PRIdPTR "\n", i, PWEAPON(j, i, SpawnTime)); buildprint(s_WEAPON, i, "_SPAWNTIME ", PWEAPON(j, i, SpawnTime), "\n");
OSD_Printf("WEAPON%d_SPAWN %" PRIdPTR "\n", i, PWEAPON(j, i, Spawn)); buildprint(s_WEAPON, i, "_SPAWN ", PWEAPON(j, i, Spawn), "\n");
OSD_Printf("WEAPON%d_SHOTSPERBURST %" PRIdPTR "\n", i, PWEAPON(j, i, ShotsPerBurst)); buildprint(s_WEAPON, i, "_SHOTSPERBURST ", PWEAPON(j, i, ShotsPerBurst), "\n");
OSD_Printf("WEAPON%d_WORKSLIKE %" PRIdPTR "\n", i, PWEAPON(j, i, WorksLike)); buildprint(s_WEAPON, i, "_WORKSLIKE ", PWEAPON(j, i, WorksLike), "\n");
OSD_Printf("WEAPON%d_INITIALSOUND %" PRIdPTR "\n", i, PWEAPON(j, i, InitialSound)); buildprint(s_WEAPON, i, "_INITIALSOUND ", PWEAPON(j, i, InitialSound), "\n");
OSD_Printf("WEAPON%d_FIRESOUND %" PRIdPTR "\n", i, PWEAPON(j, i, FireSound)); buildprint(s_WEAPON, i, "_FIRESOUND ", PWEAPON(j, i, FireSound), "\n");
OSD_Printf("WEAPON%d_SOUND2TIME %" PRIdPTR "\n", i, PWEAPON(j, i, Sound2Time)); buildprint(s_WEAPON, i, "_SOUND2TIME ", PWEAPON(j, i, Sound2Time), "\n");
OSD_Printf("WEAPON%d_SOUND2SOUND %" PRIdPTR "\n", i, PWEAPON(j, i, Sound2Sound)); buildprint(s_WEAPON, i, "_SOUND2SOUND ", PWEAPON(j, i, Sound2Sound), "\n");
OSD_Printf("WEAPON%d_RELOADSOUND1 %" PRIdPTR "\n", i, PWEAPON(j, i, ReloadSound1)); buildprint(s_WEAPON, i, "_RELOADSOUND1 ", PWEAPON(j, i, ReloadSound1), "\n");
OSD_Printf("WEAPON%d_RELOADSOUND2 %" PRIdPTR "\n", i, PWEAPON(j, i, ReloadSound2)); buildprint(s_WEAPON, i, "_RELOADSOUND2 ", PWEAPON(j, i, ReloadSound2), "\n");
OSD_Printf("WEAPON%d_SELECTSOUND %" PRIdPTR "\n", i, PWEAPON(j, i, SelectSound)); buildprint(s_WEAPON, i, "_SELECTSOUND ", PWEAPON(j, i, SelectSound), "\n");
OSD_Printf("WEAPON%d_FLASHCOLOR %" PRIdPTR "\n", i, PWEAPON(j, i, FlashColor)); buildprint(s_WEAPON, i, "_FLASHCOLOR ", PWEAPON(j, i, FlashColor), "\n");
} }
OSD_Printf("\n"); buildprint("\n");
} }
for (x=0; x<MAXSTATUS; x++) for (x=0; x<MAXSTATUS; x++)
@ -1216,30 +1215,28 @@ void G_DumpDebugInfo(void)
j = headspritestat[x]; j = headspritestat[x];
while (j >= 0) while (j >= 0)
{ {
OSD_Printf("Sprite %d (%d,%d,%d) (picnum: %d)\n",j, buildprint("Sprite ", j, " (", TrackerCast(sprite[j].x), ",", TrackerCast(sprite[j].y), ",", TrackerCast(sprite[j].z),
TrackerCast(sprite[j].x),TrackerCast(sprite[j].y),TrackerCast(sprite[j].z),TrackerCast(sprite[j].picnum)); ") (picnum: ", TrackerCast(sprite[j].picnum), ")\n");
for (i=0; i<g_gameVarCount; i++) for (i=0; i<g_gameVarCount; i++)
{ {
if (aGameVars[i].flags & (GAMEVAR_PERACTOR)) if (aGameVars[i].flags & (GAMEVAR_PERACTOR))
{ {
if (aGameVars[i].pValues[j] != aGameVars[i].defaultValue) if (aGameVars[i].pValues[j] != aGameVars[i].defaultValue)
{ {
OSD_Printf("gamevar %s ",aGameVars[i].szLabel); buildprint("gamevar ", aGameVars[i].szLabel, " ", aGameVars[i].pValues[j], " GAMEVAR_PERACTOR");
OSD_Printf("%" PRIdPTR "",aGameVars[i].pValues[j]);
OSD_Printf(" GAMEVAR_PERACTOR");
if (aGameVars[i].flags != GAMEVAR_PERACTOR) if (aGameVars[i].flags != GAMEVAR_PERACTOR)
{ {
OSD_Printf(" // "); buildprint(" // ");
if (aGameVars[i].flags & (GAMEVAR_SYSTEM)) if (aGameVars[i].flags & (GAMEVAR_SYSTEM))
{ {
OSD_Printf(" (system)"); buildprint(" (system)");
} }
} }
OSD_Printf("\n"); buildprint("\n");
} }
} }
} }
OSD_Printf("\n"); buildprint("\n");
j = nextspritestat[j]; j = nextspritestat[j];
} }
} }

View file

@ -1338,7 +1338,7 @@ static int32_t C_SetScriptSize(int32_t newsize)
if (EDUKE32_PREDICT_FALSE((intptr_t)apScript[i] < (intptr_t)&apScript[0] || (intptr_t)apScript[i] >= (intptr_t)&apScript[g_scriptSize])) if (EDUKE32_PREDICT_FALSE((intptr_t)apScript[i] < (intptr_t)&apScript[0] || (intptr_t)apScript[i] >= (intptr_t)&apScript[g_scriptSize]))
{ {
g_errorCnt++; g_errorCnt++;
initprintf("Internal compiler error at %" PRIdPTR " (0x%" PRIxPTR ")\n",i,i); buildprint("Internal compiler error at ", i, " (0x", hex(i), ")\n");
VM_ScriptInfo(&apScript[i], 16); VM_ScriptInfo(&apScript[i], 16);
} }
@ -1366,7 +1366,7 @@ static int32_t C_SetScriptSize(int32_t newsize)
bitptr = newbitptr; bitptr = newbitptr;
if (apScript != newscript) if (apScript != newscript)
{ {
initprintf("Relocating compiled code from to 0x%" PRIxPTR " to 0x%" PRIxPTR "\n", (intptr_t)apScript, (intptr_t)newscript); buildprint("Relocating compiled code from to 0x", hex((intptr_t)apScript), " to 0x", hex((intptr_t)newscript), "\n");
apScript = newscript; apScript = newscript;
} }
@ -1637,8 +1637,7 @@ static int32_t parse_hex_constant(const char *hexnum)
if (EDUKE32_PREDICT_FALSE(x > UINT32_MAX)) if (EDUKE32_PREDICT_FALSE(x > UINT32_MAX))
{ {
initprintf("%s:%d: warning: number 0x%" PRIx64 " truncated to 32 bits.\n", initprintf(g_scriptFileName, ":", g_lineNumber, ": warning: number 0x", hex(x), " truncated to 32 bits.\n");
g_scriptFileName,g_lineNumber, x);
g_warningCnt++; g_warningCnt++;
} }

View file

@ -1745,7 +1745,7 @@ skip_check:
case CON_DEBUG: case CON_DEBUG:
insptr++; insptr++;
initprintf("%" PRIdPTR "\n",*insptr++); buildprint(*insptr++, "\n");
continue; continue;
case CON_ENDOFGAME: case CON_ENDOFGAME:

View file

@ -327,40 +327,40 @@ void Gv_WriteSave(FILE *fil)
void Gv_DumpValues(void) void Gv_DumpValues(void)
{ {
OSD_Printf("// Current Game Definitions\n\n"); buildprint("// Current Game Definitions\n\n");
for (bssize_t i=0; i<g_gameVarCount; i++) for (bssize_t i=0; i<g_gameVarCount; i++)
{ {
OSD_Printf("gamevar %s ",aGameVars[i].szLabel); buildprint("gamevar ", aGameVars[i].szLabel, " ");
if (aGameVars[i].flags & (GAMEVAR_INTPTR)) if (aGameVars[i].flags & (GAMEVAR_INTPTR))
OSD_Printf("%d",*((int32_t *)aGameVars[i].global)); buildprint(*(int32_t *)aGameVars[i].global);
else if (aGameVars[i].flags & (GAMEVAR_SHORTPTR)) else if (aGameVars[i].flags & (GAMEVAR_SHORTPTR))
OSD_Printf("%d",*((int16_t *)aGameVars[i].global)); buildprint(*(int16_t *)aGameVars[i].global);
else if (aGameVars[i].flags & (GAMEVAR_CHARPTR)) else if (aGameVars[i].flags & (GAMEVAR_CHARPTR))
OSD_Printf("%d",*((char *)aGameVars[i].global)); buildprint(*(int8_t *)aGameVars[i].global);
else else
OSD_Printf("%" PRIdPTR "",aGameVars[i].global); buildprint(aGameVars[i].global);
if (aGameVars[i].flags & (GAMEVAR_PERPLAYER)) if (aGameVars[i].flags & (GAMEVAR_PERPLAYER))
OSD_Printf(" GAMEVAR_PERPLAYER"); buildprint(" GAMEVAR_PERPLAYER");
else if (aGameVars[i].flags & (GAMEVAR_PERACTOR)) else if (aGameVars[i].flags & (GAMEVAR_PERACTOR))
OSD_Printf(" GAMEVAR_PERACTOR"); buildprint(" GAMEVAR_PERACTOR");
else else
OSD_Printf(" %" PRIdPTR,aGameVars[i].flags/* & (GAMEVAR_USER_MASK)*/); buildprint(" ", aGameVars[i].flags/* & (GAMEVAR_USER_MASK)*/);
OSD_Printf(" // "); buildprint(" // ");
if (aGameVars[i].flags & (GAMEVAR_SYSTEM)) if (aGameVars[i].flags & (GAMEVAR_SYSTEM))
OSD_Printf(" (system)"); buildprint(" (system)");
if (aGameVars[i].flags & (GAMEVAR_PTR_MASK)) if (aGameVars[i].flags & (GAMEVAR_PTR_MASK))
OSD_Printf(" (pointer)"); buildprint(" (pointer)");
if (aGameVars[i].flags & (GAMEVAR_READONLY)) if (aGameVars[i].flags & (GAMEVAR_READONLY))
OSD_Printf(" (read only)"); buildprint(" (read only)");
if (aGameVars[i].flags & (GAMEVAR_SPECIAL)) if (aGameVars[i].flags & (GAMEVAR_SPECIAL))
OSD_Printf(" (special)"); buildprint(" (special)");
OSD_Printf("\n"); buildprint("\n");
} }
OSD_Printf("\n// end of game definitions\n"); buildprint("\n// end of game definitions\n");
} }
// XXX: This function is very strange. // XXX: This function is very strange.

View file

@ -641,7 +641,7 @@ static int32_t C_SetScriptSize(int32_t size)
if (apScript != newscript) if (apScript != newscript)
{ {
initprintf("Relocating compiled code from to 0x%" PRIxPTR " to 0x%" PRIxPTR "\n", (intptr_t)apScript, (intptr_t)newscript); buildprint("Relocating compiled code from to 0x", hex((intptr_t)apScript), " to 0x", hex((intptr_t)newscript), "\n");
apScript = newscript; apScript = newscript;
} }

View file

@ -451,7 +451,7 @@ void Net_HandleClientPackets(void)
if (playeridx < 0 || playeridx >= MAXPLAYERS) if (playeridx < 0 || playeridx >= MAXPLAYERS)
{ {
enet_peer_disconnect_later(event.peer, DISC_INVALID); enet_peer_disconnect_later(event.peer, DISC_INVALID);
initprintf("Invalid player id (%" PRIdPTR ") from client.\n", playeridx); buildprint("Invalid player id (", playeridx, ") from client.\n");
continue; continue;
} }