From a19dce25671ecfa28e4eb3861f8636750bf3ba68 Mon Sep 17 00:00:00 2001 From: havoc Date: Sun, 14 Jan 2007 10:19:20 +0000 Subject: [PATCH] patch from div0 that enables printf format warnings in gcc patch from div0 that fixes a lot of printf format warnings (some quite bad) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6694 d7cf8633-e32d-0410-b094-e92efae38249 --- cd_win.c | 20 ++++++++++---------- cl_main.c | 2 +- cl_parse.c | 8 ++++---- common.h | 4 ++-- console.c | 2 +- console.h | 6 +++--- csprogs.c | 1 + fs.c | 2 +- fs.h | 2 +- gl_backend.c | 2 +- gl_textures.c | 2 +- image_png.c | 2 +- menu.c | 1 + model_alias.c | 16 ++++++++-------- model_brush.c | 16 ++++++++-------- model_shared.c | 2 +- mvm_cmds.c | 2 +- netconn.c | 4 ++-- progsvm.h | 4 ++-- prvm_cmds.c | 4 ++-- prvm_edict.c | 2 +- prvm_execprogram.h | 6 +++--- quakedef.h | 9 +++++++-- r_shadow.c | 2 +- r_sky.c | 2 +- server.h | 4 ++-- snd_mix.c | 2 +- snd_win.c | 2 +- sys.h | 2 +- vid_agl.c | 14 +++++++------- vid_wgl.c | 8 ++++---- zone.c | 4 ++-- 32 files changed, 83 insertions(+), 76 deletions(-) diff --git a/cd_win.c b/cd_win.c index 5b475496..495fe020 100644 --- a/cd_win.c +++ b/cd_win.c @@ -39,7 +39,7 @@ void CDAudio_SysEject(void) DWORD dwReturn; if ((dwReturn = mciSendCommand(wDeviceID, MCI_SET, MCI_SET_DOOR_OPEN, (DWORD_PTR)NULL))) - Con_Printf("MCI_SET_DOOR_OPEN failed (%i)\n", dwReturn); + Con_Printf("MCI_SET_DOOR_OPEN failed (%x)\n", (unsigned)dwReturn); } @@ -48,7 +48,7 @@ void CDAudio_SysCloseDoor(void) DWORD dwReturn; if ((dwReturn = mciSendCommand(wDeviceID, MCI_SET, MCI_SET_DOOR_CLOSED, (DWORD_PTR)NULL))) - Con_Printf("MCI_SET_DOOR_CLOSED failed (%i)\n", dwReturn); + Con_Printf("MCI_SET_DOOR_CLOSED failed (%x)\n", (unsigned)dwReturn); } int CDAudio_SysGetAudioDiskInfo(void) @@ -111,7 +111,7 @@ int CDAudio_SysPlay (unsigned char track) dwReturn = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_TRACK | MCI_WAIT, (DWORD_PTR) (LPVOID) &mciStatusParms); if (dwReturn) { - Con_Printf("CDAudio_SysPlay: MCI_STATUS failed (%i)\n", dwReturn); + Con_Printf("CDAudio_SysPlay: MCI_STATUS failed (%x)\n", (unsigned)dwReturn); return -1; } if (mciStatusParms.dwReturn != MCI_CDA_TRACK_AUDIO) @@ -129,7 +129,7 @@ int CDAudio_SysPlay (unsigned char track) dwReturn = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_TRACK | MCI_WAIT, (DWORD_PTR) (LPVOID) &mciStatusParms); if (dwReturn) { - Con_Printf("CDAudio_SysPlay: MCI_STATUS failed (%i)\n", dwReturn); + Con_Printf("CDAudio_SysPlay: MCI_STATUS failed (%x)\n", (unsigned)dwReturn); return -1; } @@ -139,7 +139,7 @@ int CDAudio_SysPlay (unsigned char track) dwReturn = mciSendCommand(wDeviceID, MCI_PLAY, MCI_NOTIFY | MCI_FROM | MCI_TO, (DWORD_PTR)(LPVOID) &mciPlayParms); if (dwReturn) { - Con_Printf("CDAudio_SysPlay: MCI_PLAY failed (%i)\n", dwReturn); + Con_Printf("CDAudio_SysPlay: MCI_PLAY failed (%x)\n", (unsigned)dwReturn); return -1; } @@ -153,7 +153,7 @@ int CDAudio_SysStop (void) if ((dwReturn = mciSendCommand(wDeviceID, MCI_STOP, 0, (DWORD_PTR)NULL))) { - Con_Printf("MCI_STOP failed (%i)\n", dwReturn); + Con_Printf("MCI_STOP failed (%x)\n", (unsigned)dwReturn); return -1; } return 0; @@ -167,7 +167,7 @@ int CDAudio_SysPause (void) mciGenericParms.dwCallback = (DWORD_PTR)mainwindow; if ((dwReturn = mciSendCommand(wDeviceID, MCI_PAUSE, 0, (DWORD_PTR)(LPVOID) &mciGenericParms))) { - Con_Printf("MCI_PAUSE failed (%i)\n", dwReturn); + Con_Printf("MCI_PAUSE failed (%x)\n", (unsigned)dwReturn); return -1; } return 0; @@ -185,7 +185,7 @@ int CDAudio_SysResume (void) dwReturn = mciSendCommand(wDeviceID, MCI_PLAY, MCI_TO | MCI_NOTIFY, (DWORD_PTR)(LPVOID) &mciPlayParms); if (dwReturn) { - Con_Printf("CDAudio_SysResume: MCI_PLAY failed (%i)\n", dwReturn); + Con_Printf("CDAudio_SysResume: MCI_PLAY failed (%x)\n", (unsigned)dwReturn); return -1; } return 0; @@ -244,7 +244,7 @@ int CDAudio_SysStartup (void) mciOpenParms.lpstrDeviceType = "cdaudio"; if ((dwReturn = mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_SHAREABLE, (DWORD_PTR) (LPVOID) &mciOpenParms))) { - Con_Printf("CDAudio_SysStartup: MCI_OPEN failed (%i)\n", dwReturn); + Con_Printf("CDAudio_SysStartup: MCI_OPEN failed (%x)\n", (unsigned)dwReturn); return -1; } wDeviceID = mciOpenParms.wDeviceID; @@ -253,7 +253,7 @@ int CDAudio_SysStartup (void) mciSetParms.dwTimeFormat = MCI_FORMAT_TMSF; if ((dwReturn = mciSendCommand(wDeviceID, MCI_SET, MCI_SET_TIME_FORMAT, (DWORD_PTR)(LPVOID) &mciSetParms))) { - Con_Printf("CDAudio_SysStartup: MCI_SET_TIME_FORMAT failed (%i)\n", dwReturn); + Con_Printf("CDAudio_SysStartup: MCI_SET_TIME_FORMAT failed (%x)\n", (unsigned)dwReturn); mciSendCommand(wDeviceID, MCI_CLOSE, 0, (DWORD_PTR)NULL); return -1; } diff --git a/cl_main.c b/cl_main.c index ad44adc4..01a98318 100644 --- a/cl_main.c +++ b/cl_main.c @@ -208,7 +208,7 @@ void CL_SetInfo(const char *key, const char *value, qboolean send, qboolean allo if (strchr(key, '\"') || strchr(value, '\"') || (!allowstarkey && key[0] == '*') || (!allowmodel && (!strcasecmp(key, "pmodel") || !strcasecmp(key, "emodel")))) { if (!quiet) - Con_Printf("Can't setinfo \"%s\" \"%s\"\n"); + Con_Printf("Can't setinfo \"%s\" \"%s\"\n", key, value); return; } InfoString_SetValue(cls.userinfo, sizeof(cls.userinfo), key, value); diff --git a/cl_parse.c b/cl_parse.c index 3cb9084f..3cc5820a 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -639,7 +639,7 @@ static void QW_CL_ParseModelList(void) if (nummodels==MAX_MODELS) Host_Error("Server sent too many model precaches"); if (strlen(str) >= MAX_QPATH) - Host_Error("Server sent a precache name of %i characters (max %i)", strlen(str), MAX_QPATH - 1); + Host_Error("Server sent a precache name of %i characters (max %i)", (int)strlen(str), MAX_QPATH - 1); strlcpy(cl.model_name[nummodels], str, sizeof (cl.model_name[nummodels])); } @@ -673,7 +673,7 @@ static void QW_CL_ParseSoundList(void) if (numsounds==MAX_SOUNDS) Host_Error("Server sent too many sound precaches"); if (strlen(str) >= MAX_QPATH) - Host_Error("Server sent a precache name of %i characters (max %i)", strlen(str), MAX_QPATH - 1); + Host_Error("Server sent a precache name of %i characters (max %i)", (int)strlen(str), MAX_QPATH - 1); strlcpy(cl.sound_name[numsounds], str, sizeof (cl.sound_name[numsounds])); } @@ -1079,7 +1079,7 @@ void CL_ParseServerInfo (void) if (nummodels==MAX_MODELS) Host_Error ("Server sent too many model precaches"); if (strlen(str) >= MAX_QPATH) - Host_Error ("Server sent a precache name of %i characters (max %i)", strlen(str), MAX_QPATH - 1); + Host_Error ("Server sent a precache name of %i characters (max %i)", (int)strlen(str), MAX_QPATH - 1); strlcpy (cl.model_name[nummodels], str, sizeof (cl.model_name[nummodels])); } // parse sound precache list @@ -1091,7 +1091,7 @@ void CL_ParseServerInfo (void) if (numsounds==MAX_SOUNDS) Host_Error("Server sent too many sound precaches"); if (strlen(str) >= MAX_QPATH) - Host_Error("Server sent a precache name of %i characters (max %i)", strlen(str), MAX_QPATH - 1); + Host_Error("Server sent a precache name of %i characters (max %i)", (int)strlen(str), MAX_QPATH - 1); strlcpy (cl.sound_name[numsounds], str, sizeof (cl.sound_name[numsounds])); } diff --git a/common.h b/common.h index 64eecf31..816a8fa9 100644 --- a/common.h +++ b/common.h @@ -213,7 +213,7 @@ void COM_Init (void); void COM_Shutdown (void); void COM_InitGameType (void); -char *va(const char *format, ...); +char *va(const char *format, ...) DP_FUNC_PRINTF(1); // does a varargs printf into a temp buffer @@ -225,7 +225,7 @@ char *va(const char *format, ...); // return the number of printed characters, excluding the final '\0' // or return -1 if the buffer isn't big enough to contain the entire string. // buffer is ALWAYS null-terminated -extern int dpsnprintf (char *buffer, size_t buffersize, const char *format, ...); +extern int dpsnprintf (char *buffer, size_t buffersize, const char *format, ...) DP_FUNC_PRINTF(3); extern int dpvsnprintf (char *buffer, size_t buffersize, const char *format, va_list args); // A bunch of functions are forbidden for security reasons (and also to please MSVS 2005, for some of them) diff --git a/console.c b/console.c index f2226351..03671837 100644 --- a/console.c +++ b/console.c @@ -406,7 +406,7 @@ void Con_ConDump_f (void) file = FS_Open(Cmd_Argv(1), "wb", false, false); if (!file) { - Con_Printf("condump: unable to write file \"%s\"\n", file); + Con_Printf("condump: unable to write file \"%s\"\n", Cmd_Argv(1)); return; } // iterate over the entire console history buffer line by line diff --git a/console.h b/console.h index 4b8048c9..1849f670 100644 --- a/console.h +++ b/console.h @@ -37,9 +37,9 @@ void Con_Init (void); void Con_Init_Commands (void); void Con_DrawConsole (int lines); void Con_Print(const char *txt); -void Con_Printf(const char *fmt, ...); +void Con_Printf(const char *fmt, ...) DP_FUNC_PRINTF(1); void Con_DPrint(const char *msg); -void Con_DPrintf(const char *fmt, ...); +void Con_DPrintf(const char *fmt, ...) DP_FUNC_PRINTF(1); void Con_Clear_f (void); void Con_DrawNotify (void); void Con_ClearNotify (void); @@ -65,7 +65,7 @@ void Log_Init (void); void Log_Close (void); void Log_Start (void); -void Log_Printf(const char *logfilename, const char *fmt, ...); +void Log_Printf(const char *logfilename, const char *fmt, ...) DP_FUNC_PRINTF(2); #endif diff --git a/csprogs.c b/csprogs.c index 12431206..735adbb2 100644 --- a/csprogs.c +++ b/csprogs.c @@ -96,6 +96,7 @@ static void CL_VM_FindEdictFieldOffsets (void) } } +void CL_VM_Error (const char *format, ...) DP_FUNC_PRINTF(1); void CL_VM_Error (const char *format, ...) //[515]: hope it will be never executed =) { char errorstring[4096]; diff --git a/fs.c b/fs.c index 89f0086c..8bf3d1c5 100644 --- a/fs.c +++ b/fs.c @@ -1434,7 +1434,7 @@ qfile_t *FS_OpenPackedFile (pack_t* pack, int pack_ind) if (lseek (pack->handle, pfile->offset, SEEK_SET) == -1) { Con_Printf ("FS_OpenPackedFile: can't lseek to %s in %s (offset: %d)\n", - pfile->name, pack->filename, pfile->offset); + pfile->name, pack->filename, (int) pfile->offset); return NULL; } diff --git a/fs.h b/fs.h index 0a9837b1..11b99324 100644 --- a/fs.h +++ b/fs.h @@ -58,7 +58,7 @@ int FS_Close (qfile_t* file); fs_offset_t FS_Write (qfile_t* file, const void* data, size_t datasize); fs_offset_t FS_Read (qfile_t* file, void* buffer, size_t buffersize); int FS_Print(qfile_t* file, const char *msg); -int FS_Printf(qfile_t* file, const char* format, ...); +int FS_Printf(qfile_t* file, const char* format, ...) DP_FUNC_PRINTF(2); int FS_VPrintf(qfile_t* file, const char* format, va_list ap); int FS_Getc (qfile_t* file); int FS_UnGetc (qfile_t* file, unsigned char c); diff --git a/gl_backend.c b/gl_backend.c index 50d37a71..b77e5fb9 100644 --- a/gl_backend.c +++ b/gl_backend.c @@ -865,7 +865,7 @@ void R_Mesh_Draw(int firstvertex, int numvertices, int numtriangles, const int * unsigned int numelements = numtriangles * 3; if (numvertices < 3 || numtriangles < 1) { - Con_Printf("R_Mesh_Draw(%d, %d, %d, %08p);\n", firstvertex, numvertices, numtriangles, elements); + Con_Printf("R_Mesh_Draw(%d, %d, %d, %8p);\n", firstvertex, numvertices, numtriangles, elements); return; } CHECKGLERROR diff --git a/gl_textures.c b/gl_textures.c index c3e200fb..8ac8d6ca 100644 --- a/gl_textures.c +++ b/gl_textures.c @@ -856,7 +856,7 @@ static rtexture_t *R_SetupTexture(rtexturepool_t *rtexturepool, const char *iden size = width * height * depth * sides * texinfo->inputbytesperpixel; if (size < 1) { - Con_Printf ("R_LoadTexture: bogus texture size (%dx%dx%dx%dbppx%dsides = %d bytes)\n", width, height, depth, texinfo->inputbytesperpixel * 8, sides); + Con_Printf ("R_LoadTexture: bogus texture size (%dx%dx%dx%dbppx%dsides = %d bytes)\n", width, height, depth, texinfo->inputbytesperpixel * 8, sides, size); return NULL; } diff --git a/image_png.c b/image_png.c index 2f8e76a7..d9d7a500 100644 --- a/image_png.c +++ b/image_png.c @@ -205,7 +205,7 @@ void PNG_fReadData(void *png, unsigned char *data, size_t length) l = my_png.tmpBuflength - my_png.tmpi; if (l < length) { - Con_Printf("PNG_fReadData: overrun by %i bytes\n", length - l); + Con_Printf("PNG_fReadData: overrun by %i bytes\n", (int)(length - l)); // a read going past the end of the file, fill in the remaining bytes // with 0 just to be consistent memset(data + l, 0, length - l); diff --git a/menu.c b/menu.c index 3a0f0d7c..9f84b008 100644 --- a/menu.c +++ b/menu.c @@ -4840,6 +4840,7 @@ static mfunction_t *m_keyup; void MR_SetRouting (qboolean forceold); +void MP_Error(const char *format, ...) DP_FUNC_PRINTF(1); void MP_Error(const char *format, ...) { static qboolean processingError = false; diff --git a/model_alias.c b/model_alias.c index 03be060d..e3ad4024 100644 --- a/model_alias.c +++ b/model_alias.c @@ -1452,7 +1452,7 @@ void Mod_ZYMOTICMODEL_Load(model_t *mod, void *buffer, void *bufferend) pinmodel = (zymtype1header_t *)buffer; pbase = (unsigned char *)buffer; if (memcmp(pinmodel->id, "ZYMOTICMODEL", 12)) - Host_Error ("Mod_ZYMOTICMODEL_Load: %s is not a zymotic model"); + Host_Error ("Mod_ZYMOTICMODEL_Load: %s is not a zymotic model", loadmodel->name); if (BigLong(pinmodel->type) != 1) Host_Error ("Mod_ZYMOTICMODEL_Load: only type 1 (skeletal pose) models are currently supported (name = %s)", loadmodel->name); @@ -1497,12 +1497,12 @@ void Mod_ZYMOTICMODEL_Load(model_t *mod, void *buffer, void *bufferend) if (pheader->numtris < 1 || pheader->numverts < 3 || pheader->numshaders < 1) { - Con_Printf("%s has no geometry\n"); + Con_Printf("%s has no geometry\n", loadmodel->name); return; } if (pheader->numscenes < 1 || pheader->lump_poses.length < (int)sizeof(float[3][4])) { - Con_Printf("%s has no animations\n"); + Con_Printf("%s has no animations\n", loadmodel->name); return; } @@ -1762,7 +1762,7 @@ void Mod_DARKPLACESMODEL_Load(model_t *mod, void *buffer, void *bufferend) pheader = (dpmheader_t *)buffer; pbase = (unsigned char *)buffer; if (memcmp(pheader->id, "DARKPLACESMODEL\0", 16)) - Host_Error ("Mod_DARKPLACESMODEL_Load: %s is not a darkplaces model"); + Host_Error ("Mod_DARKPLACESMODEL_Load: %s is not a darkplaces model", loadmodel->name); if (BigLong(pheader->type) != 2) Host_Error ("Mod_DARKPLACESMODEL_Load: only type 2 (hierarchical skeletal pose) models are currently supported (name = %s)", loadmodel->name); @@ -1790,12 +1790,12 @@ void Mod_DARKPLACESMODEL_Load(model_t *mod, void *buffer, void *bufferend) if (pheader->num_bones < 1 || pheader->num_meshs < 1) { - Con_Printf("%s has no geometry\n"); + Con_Printf("%s has no geometry\n", loadmodel->name); return; } if (pheader->num_frames < 1) { - Con_Printf("%s has no frames\n"); + Con_Printf("%s has no frames\n", loadmodel->name); return; } @@ -2063,7 +2063,7 @@ void Mod_PSKMODEL_Load(model_t *mod, void *buffer, void *bufferend) pchunk = (pskchunk_t *)buffer; if (strcmp(pchunk->id, "ACTRHEAD")) - Host_Error ("Mod_PSKMODEL_Load: %s is not an Unreal Engine ActorX (.psk + .psa) model"); + Host_Error ("Mod_PSKMODEL_Load: %s is not an Unreal Engine ActorX (.psk + .psa) model", loadmodel->name); loadmodel->type = mod_alias; loadmodel->DrawSky = NULL; @@ -2298,7 +2298,7 @@ void Mod_PSKMODEL_Load(model_t *mod, void *buffer, void *bufferend) // positions from the psk, but this is hard for me to implement // and people can easily make animations that match. if (numanimbones != numbones) - Host_Error("%s: this loader only supports animations with the same bones as the mesh"); + Host_Error("%s: this loader only supports animations with the same bones as the mesh", loadmodel->name); for (index = 0, p = (pskboneinfo_t *)animbuffer;index < numrecords;index++, p++) { p->numchildren = LittleLong(p->numchildren); diff --git a/model_brush.c b/model_brush.c index 47765028..75398747 100644 --- a/model_brush.c +++ b/model_brush.c @@ -1130,7 +1130,7 @@ static void Mod_Q1BSP_DecompressVis(const unsigned char *in, const unsigned char { if (in == inend) { - Con_Printf("Mod_Q1BSP_DecompressVis: input underrun on model \"%s\" (decompressed %i of %i output bytes)\n", loadmodel->name, out - outstart, outend - outstart); + Con_Printf("Mod_Q1BSP_DecompressVis: input underrun on model \"%s\" (decompressed %i of %i output bytes)\n", loadmodel->name, (int)(out - outstart), (int)(outend - outstart)); return; } c = *in++; @@ -1140,14 +1140,14 @@ static void Mod_Q1BSP_DecompressVis(const unsigned char *in, const unsigned char { if (in == inend) { - Con_Printf("Mod_Q1BSP_DecompressVis: input underrun (during zero-run) on model \"%s\" (decompressed %i of %i output bytes)\n", loadmodel->name, out - outstart, outend - outstart); + Con_Printf("Mod_Q1BSP_DecompressVis: input underrun (during zero-run) on model \"%s\" (decompressed %i of %i output bytes)\n", loadmodel->name, (int)(out - outstart), (int)(outend - outstart)); return; } for (c = *in++;c > 0;c--) { if (out == outend) { - Con_Printf("Mod_Q1BSP_DecompressVis: output overrun on model \"%s\" (decompressed %i of %i output bytes)\n", loadmodel->name, out - outstart, outend - outstart); + Con_Printf("Mod_Q1BSP_DecompressVis: output overrun on model \"%s\" (decompressed %i of %i output bytes)\n", loadmodel->name, (int)(out - outstart), (int)(outend - outstart)); return; } *out++ = 0; @@ -1601,7 +1601,7 @@ static void Mod_Q1BSP_LoadLighting(lump_t *l) else if (filesize == 8) Con_Print("Empty .lit file, ignoring\n"); else - Con_Printf("Corrupt .lit file (file size %i bytes, should be %i bytes), ignoring\n", filesize, 8 + l->filelen * 3); + Con_Printf("Corrupt .lit file (file size %i bytes, should be %i bytes), ignoring\n", (int) filesize, (int) (8 + l->filelen * 3)); if (data) { Mem_Free(data); @@ -2338,7 +2338,7 @@ static void Mod_Q1BSP_LoadLeafs(lump_t *l) out->numleafsurfaces = LittleShort(in->nummarksurfaces); if (out->firstleafsurface < 0 || LittleShort(in->firstmarksurface) + out->numleafsurfaces > loadmodel->brush.num_leafsurfaces) { - Con_Printf("Mod_Q1BSP_LoadLeafs: invalid leafsurface range %i:%i outside range %i:%i\n", out->firstleafsurface, out->firstleafsurface + out->numleafsurfaces, 0, loadmodel->brush.num_leafsurfaces); + Con_Printf("Mod_Q1BSP_LoadLeafs: invalid leafsurface range %i:%i outside range %i:%i\n", (int)(out->firstleafsurface - loadmodel->brush.data_leafsurfaces), (int)(out->firstleafsurface + out->numleafsurfaces - loadmodel->brush.data_leafsurfaces), 0, loadmodel->brush.num_leafsurfaces); out->firstleafsurface = NULL; out->numleafsurfaces = 0; } @@ -5245,9 +5245,9 @@ static void Mod_Q3BSP_LoadLightGrid(lump_t *l) if (l->filelen) { if (l->filelen < count * (int)sizeof(*in)) - Host_Error("Mod_Q3BSP_LoadLightGrid: invalid lightgrid lump size %i bytes, should be %i bytes (%ix%ix%i)", l->filelen, count * sizeof(*in), loadmodel->brushq3.num_lightgrid_dimensions[0], loadmodel->brushq3.num_lightgrid_dimensions[1], loadmodel->brushq3.num_lightgrid_dimensions[2]); + Host_Error("Mod_Q3BSP_LoadLightGrid: invalid lightgrid lump size %i bytes, should be %i bytes (%ix%ix%i)", l->filelen, (int)(count * sizeof(*in)), loadmodel->brushq3.num_lightgrid_dimensions[0], loadmodel->brushq3.num_lightgrid_dimensions[1], loadmodel->brushq3.num_lightgrid_dimensions[2]); if (l->filelen != count * (int)sizeof(*in)) - Con_Printf("Mod_Q3BSP_LoadLightGrid: Warning: calculated lightgrid size %i bytes does not match lump size %i", count * sizeof(*in), l->filelen); + Con_Printf("Mod_Q3BSP_LoadLightGrid: Warning: calculated lightgrid size %i bytes does not match lump size %i\n", (int)(count * sizeof(*in)), l->filelen); out = (q3dlightgrid_t *)Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); loadmodel->brushq3.data_lightgrid = out; loadmodel->brushq3.num_lightgrid = count; @@ -5288,7 +5288,7 @@ static void Mod_Q3BSP_LoadPVS(lump_t *l) Host_Error("Mod_Q3BSP_LoadPVS: (chainlength = %i) < ((numclusters = %i) + 7) / 8", loadmodel->brush.num_pvsclusterbytes, loadmodel->brush.num_pvsclusters); totalchains = loadmodel->brush.num_pvsclusterbytes * loadmodel->brush.num_pvsclusters; if (l->filelen < totalchains + (int)sizeof(*in)) - Host_Error("Mod_Q3BSP_LoadPVS: lump too small ((numclusters = %i) * (chainlength = %i) + sizeof(q3dpvs_t) == %i bytes, lump is %i bytes)", loadmodel->brush.num_pvsclusters, loadmodel->brush.num_pvsclusterbytes, totalchains + sizeof(*in), l->filelen); + Host_Error("Mod_Q3BSP_LoadPVS: lump too small ((numclusters = %i) * (chainlength = %i) + sizeof(q3dpvs_t) == %i bytes, lump is %i bytes)", loadmodel->brush.num_pvsclusters, loadmodel->brush.num_pvsclusterbytes, (int)(totalchains + sizeof(*in)), l->filelen); loadmodel->brush.data_pvsclusters = (unsigned char *)Mem_Alloc(loadmodel->mempool, totalchains); memcpy(loadmodel->brush.data_pvsclusters, (unsigned char *)(in + 1), totalchains); diff --git a/model_shared.c b/model_shared.c index ad05c4e4..a613449e 100644 --- a/model_shared.c +++ b/model_shared.c @@ -381,7 +381,7 @@ static void Mod_Print(void) Con_Print("Loaded models:\n"); for (i = 0, mod = mod_known;i < mod_numknown;i++, mod++) if (mod->name[0]) - Con_Printf("%4iK %s\n", mod->mempool ? (mod->mempool->totalsize + 1023) / 1024 : 0, mod->name); + Con_Printf("%4iK %s\n", mod->mempool ? (int)((mod->mempool->totalsize + 1023) / 1024) : 0, mod->name); } /* diff --git a/mvm_cmds.c b/mvm_cmds.c index b2f0d790..49848737 100644 --- a/mvm_cmds.c +++ b/mvm_cmds.c @@ -262,7 +262,7 @@ void VM_M_writetofile(void) ent = PRVM_G_EDICT(OFS_PARM1); if(ent->priv.required->free) { - VM_Warning("VM_M_writetofile: %s: entity %i is free !\n", PRVM_NAME, PRVM_EDICT_NUM(OFS_PARM1)); + VM_Warning("VM_M_writetofile: %s: entity %i is free !\n", PRVM_NAME, PRVM_NUM_FOR_EDICT(ent)); return; } diff --git a/netconn.c b/netconn.c index 02f6b5a9..ba857902 100755 --- a/netconn.c +++ b/netconn.c @@ -580,7 +580,7 @@ int NetConn_SendUnreliableMessage(netconn_t *conn, sizebuf_t *data, protocolvers { if (conn->message.cursize > (int)sizeof(conn->sendMessage)) { - Con_Printf("NetConn_SendUnreliableMessage: reliable message too big (%u > %u)\n", conn->message.cursize, sizeof(conn->sendMessage)); + Con_Printf("NetConn_SendUnreliableMessage: reliable message too big (%u > %u)\n", conn->message.cursize, (int)sizeof(conn->sendMessage)); conn->message.overflowed = true; return -1; } @@ -2504,7 +2504,7 @@ void NetConn_Init(void) { if (LHNETADDRESS_FromString(&tempaddress, com_argv[i + 1], 0) == 1) { - Con_Printf("-ip option used, setting net_address to \"%s\"\n"); + Con_Printf("-ip option used, setting net_address to \"%s\"\n", com_argv[i + 1]); Cvar_SetQuick(&net_address, com_argv[i + 1]); } else diff --git a/progsvm.h b/progsvm.h index b0ed47bd..7e6250a4 100644 --- a/progsvm.h +++ b/progsvm.h @@ -382,7 +382,7 @@ typedef struct prvm_prog_s void (*init_cmd)(void); // [INIT] used by PRVM_InitProg void (*reset_cmd)(void); // [INIT] used by PRVM_ResetProg - void (*error_cmd)(const char *format, ...); // [INIT] + void (*error_cmd)(const char *format, ...) DP_FUNC_PRINTF(1); // [INIT] } prvm_prog_t; @@ -551,7 +551,7 @@ qboolean PRVM_ProgLoaded(int prognr); int PRVM_GetProgNr(void); -void VM_Warning(const char *fmt, ...); +void VM_Warning(const char *fmt, ...) DP_FUNC_PRINTF(1); // TODO: fill in the params //void PRVM_Create(); diff --git a/prvm_cmds.c b/prvm_cmds.c index 20d2dd03..6ff3db25 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -146,7 +146,7 @@ void VM_objerror (void) char string[VM_STRINGTEMP_LENGTH]; VM_VarString(0, string, sizeof(string)); - Con_Printf("======OBJECT ERROR======\n", PRVM_NAME, PRVM_GetString(prog->xfunction->s_name), string); + Con_Printf("======OBJECT ERROR======\n"); // , PRVM_NAME, PRVM_GetString(prog->xfunction->s_name), string); // or include them? FIXME if(prog->self) { ed = PRVM_G_EDICT (prog->self->ofs); @@ -2583,7 +2583,7 @@ void VM_freepic(void) s = PRVM_G_STRING(OFS_PARM0); if(!s) - PRVM_ERROR ("VM_freepic: %s: NULL"); + PRVM_ERROR ("VM_freepic: NULL"); VM_CheckEmptyString (s); diff --git a/prvm_edict.c b/prvm_edict.c index 17c625f1..5f75aa7b 100644 --- a/prvm_edict.c +++ b/prvm_edict.c @@ -1310,7 +1310,7 @@ void PRVM_LoadProgs (const char * filename, int numrequiredfunc, char **required if (prog->progs == NULL || filesize < (fs_offset_t)sizeof(dprograms_t)) PRVM_ERROR ("PRVM_LoadProgs: couldn't load %s for %s", filename, PRVM_NAME); - Con_DPrintf("%s programs occupy %iK.\n", PRVM_NAME, filesize/1024); + Con_DPrintf("%s programs occupy %iK.\n", PRVM_NAME, (int)(filesize/1024)); prog->filecrc = CRC_Block((unsigned char *)prog->progs, filesize); diff --git a/prvm_execprogram.h b/prvm_execprogram.h index 82f1a97a..46ab0060 100644 --- a/prvm_execprogram.h +++ b/prvm_execprogram.h @@ -247,7 +247,7 @@ { prog->xstatement = st - prog->statements; PRVM_Profile(1<<30, 1000000); - PRVM_ERROR("runaway loop counter hit limit of %d jumps\ntip: read above for list of most-executed functions", jumpcount, PRVM_NAME); + PRVM_ERROR("%s runaway loop counter hit limit of %d jumps\ntip: read above for list of most-executed functions", PRVM_NAME, jumpcount); } } break; @@ -262,7 +262,7 @@ { prog->xstatement = st - prog->statements; PRVM_Profile(1<<30, 1000000); - PRVM_ERROR("runaway loop counter hit limit of %d jumps\ntip: read above for list of most-executed functions", jumpcount, PRVM_NAME); + PRVM_ERROR("%s runaway loop counter hit limit of %d jumps\ntip: read above for list of most-executed functions", PRVM_NAME, jumpcount); } } break; @@ -275,7 +275,7 @@ { prog->xstatement = st - prog->statements; PRVM_Profile(1<<30, 1000000); - PRVM_ERROR("runaway loop counter hit limit of %d jumps\ntip: read above for list of most-executed functions", jumpcount, PRVM_NAME); + PRVM_ERROR("%s runaway loop counter hit limit of %d jumps\ntip: read above for list of most-executed functions", PRVM_NAME, jumpcount); } break; diff --git a/quakedef.h b/quakedef.h index e0bdf860..f0738de0 100644 --- a/quakedef.h +++ b/quakedef.h @@ -22,6 +22,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef QUAKEDEF_H #define QUAKEDEF_H +#ifdef __GNUC__ +#define DP_FUNC_PRINTF(n) __attribute__ ((format (printf, n, n+1))) +#else +#define DP_FUNC_PRINTF(n) +#endif #include #include @@ -238,9 +243,9 @@ void Host_InitCommands(void); void Host_Main(void); void Host_Shutdown(void); void Host_StartVideo(void); -void Host_Error(const char *error, ...); +void Host_Error(const char *error, ...) DP_FUNC_PRINTF(1); void Host_Quit_f(void); -void Host_ClientCommands(const char *fmt, ...); +void Host_ClientCommands(const char *fmt, ...) DP_FUNC_PRINTF(1); void Host_ShutdownServer(void); void Host_Reconnect_f(void); diff --git a/r_shadow.c b/r_shadow.c index c1a55d4c..69ffabf3 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -681,7 +681,7 @@ void R_Shadow_VolumeFromList(int numverts, int numtris, const float *invertex3f, int tris, outverts; if (projectdistance < 0.1) { - Con_Printf("R_Shadow_Volume: projectdistance %f\n"); + Con_Printf("R_Shadow_Volume: projectdistance %f\n", projectdistance); return; } if (!numverts || !nummarktris) diff --git a/r_sky.c b/r_sky.c index bf2c009e..403e4ad7 100644 --- a/r_sky.c +++ b/r_sky.c @@ -138,7 +138,7 @@ int R_SetSkyBox(const char *sky) if (strlen(sky) > 1000) { - Con_Printf("sky name too long (%i, max is 1000)\n", strlen(sky)); + Con_Printf("sky name too long (%i, max is 1000)\n", (int)strlen(sky)); return false; } diff --git a/server.h b/server.h index 974374ef..41947092 100644 --- a/server.h +++ b/server.h @@ -336,9 +336,9 @@ void SV_AddUpdates (void); void SV_ClientThink (void); void SV_ClientPrint(const char *msg); -void SV_ClientPrintf(const char *fmt, ...); +void SV_ClientPrintf(const char *fmt, ...) DP_FUNC_PRINTF(1); void SV_BroadcastPrint(const char *msg); -void SV_BroadcastPrintf(const char *fmt, ...); +void SV_BroadcastPrintf(const char *fmt, ...) DP_FUNC_PRINTF(1); void SV_Physics (void); void SV_Physics_ClientEntity (prvm_edict_t *ent); diff --git a/snd_mix.c b/snd_mix.c index 529308b6..dc2a1474 100644 --- a/snd_mix.c +++ b/snd_mix.c @@ -242,7 +242,7 @@ static qboolean SND_PaintChannel (channel_t *ch, unsigned int count) if (sb == NULL) { Con_DPrintf("SND_PaintChannel: ERROR: can't get sound buffer from sfx \"%s\"\n", - ch->sfx->name, count); + ch->sfx->name); // , count); // or add this? FIXME } else { diff --git a/snd_win.c b/snd_win.c index 2a5fa83f..06aed2bb 100644 --- a/snd_win.c +++ b/snd_win.c @@ -326,7 +326,7 @@ static sndinitstat SndSys_InitDirectSound (const snd_format_t* requested) requested->speed != format.Format.nSamplesPerSec) { Con_Printf("DS:CreateSoundBuffer Failed (%d): channels=%u, width=%u, speed=%u\n", - result, format.Format.nChannels, format.Format.wBitsPerSample / 8, format.Format.nSamplesPerSec); + (int)result, (unsigned)format.Format.nChannels, (unsigned)format.Format.wBitsPerSample / 8, (unsigned)format.Format.nSamplesPerSec); SndSys_Shutdown (); return SIS_FAILURE; } diff --git a/sys.h b/sys.h index 278c7982..d02ae244 100644 --- a/sys.h +++ b/sys.h @@ -61,7 +61,7 @@ char *Sys_TimeString(const char *timeformat); // // system IO interface (these are the sys functions that need to be implemented in a new driver atm) // -void Sys_Error (const char *error, ...); +void Sys_Error (const char *error, ...) DP_FUNC_PRINTF(1); // an error will cause the entire program to exit void Sys_PrintToTerminal(const char *text); diff --git a/vid_agl.c b/vid_agl.c index de1775c2..191e7e56 100644 --- a/vid_agl.c +++ b/vid_agl.c @@ -433,7 +433,7 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate carbonError = CreateNewWindow(kDocumentWindowClass, kWindowStandardFloatingAttributes | kWindowStandardHandlerAttribute, &windowBounds, &window); if (carbonError != noErr || window == NULL) { - Con_Printf("Unable to create window (error %d)\n", carbonError); + Con_Printf("Unable to create window (error %u)\n", (unsigned)carbonError); return false; } @@ -739,7 +739,7 @@ void Sys_SendKeyEvents(void) } default: - Con_Printf (">> kEventClassMouse (UNKNOWN eventKind: %d) <<\n", eventKind); + Con_Printf (">> kEventClassMouse (UNKNOWN eventKind: %u) <<\n", (unsigned)eventKind); break; } } @@ -781,14 +781,14 @@ void Sys_SendKeyEvents(void) break; default: - Con_Printf (">> kEventClassKeyboard (UNKNOWN eventKind: %d) <<\n", eventKind); + Con_Printf (">> kEventClassKeyboard (UNKNOWN eventKind: %u) <<\n", (unsigned)eventKind); break; } break; } case kEventClassTextInput: - Con_Printf(">> kEventClassTextInput (%d) <<\n", eventKind); + Con_Printf(">> kEventClassTextInput (%d) <<\n", (int)eventKind); break; case kEventClassApplication: @@ -806,7 +806,7 @@ void Sys_SendKeyEvents(void) case kEventAppActiveWindowChanged: break; default: - Con_Printf(">> kEventClassApplication (UNKNOWN eventKind: %d) <<\n", eventKind); + Con_Printf(">> kEventClassApplication (UNKNOWN eventKind: %u) <<\n", (unsigned)eventKind); break; } break; @@ -817,7 +817,7 @@ void Sys_SendKeyEvents(void) case kEventAppleEvent : break; default: - Con_Printf(">> kEventClassAppleEvent (UNKNOWN eventKind: %d) <<\n", eventKind); + Con_Printf(">> kEventClassAppleEvent (UNKNOWN eventKind: %u) <<\n", (unsigned)eventKind); break; } break; @@ -828,7 +828,7 @@ void Sys_SendKeyEvents(void) case kEventWindowUpdate : break; default: - Con_Printf(">> kEventClassWindow (UNKNOWN eventKind: %d) <<\n", eventKind); + Con_Printf(">> kEventClassWindow (UNKNOWN eventKind: %u) <<\n", (unsigned)eventKind); break; } break; diff --git a/vid_wgl.c b/vid_wgl.c index 6c589895..d0954d01 100644 --- a/vid_wgl.c +++ b/vid_wgl.c @@ -865,7 +865,7 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp, int refreshrat mainwindow = CreateWindowEx (ExWindowStyle, "DarkPlacesWindowClass", gamename, WindowStyle, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, NULL, NULL, global_hInstance, NULL); if (!mainwindow) { - Con_Printf("CreateWindowEx(%d, %s, %s, %d, %d, %d, %d, %d, %p, %p, %d, %p) failed\n", ExWindowStyle, "DarkPlacesWindowClass", gamename, WindowStyle, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, NULL, NULL, global_hInstance, NULL); + Con_Printf("CreateWindowEx(%d, %s, %s, %d, %d, %d, %d, %d, %p, %p, %d, %p) failed\n", (int)ExWindowStyle, "DarkPlacesWindowClass", gamename, (int)WindowStyle, (int)(rect.left), (int)(rect.top), (int)(rect.right - rect.left), (int)(rect.bottom - rect.top), NULL, NULL, (int)global_hInstance, NULL); VID_Shutdown(); return false; } @@ -906,14 +906,14 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp, int refreshrat if ((pixelformat = ChoosePixelFormat(baseDC, &pfd)) == 0) { VID_Shutdown(); - Con_Printf("ChoosePixelFormat(%d, %p) failed\n", baseDC, &pfd); + Con_Printf("ChoosePixelFormat(%d, %p) failed\n", (int)baseDC, &pfd); return false; } if (SetPixelFormat(baseDC, pixelformat, &pfd) == false) { VID_Shutdown(); - Con_Printf("SetPixelFormat(%d, %d, %p) failed\n", baseDC, pixelformat, &pfd); + Con_Printf("SetPixelFormat(%d, %d, %p) failed\n", (int)baseDC, pixelformat, &pfd); return false; } @@ -934,7 +934,7 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp, int refreshrat if (!qwglMakeCurrent(baseDC, baseRC)) { VID_Shutdown(); - Con_Printf("wglMakeCurrent(%d, %d) failed\n", baseDC, baseRC); + Con_Printf("wglMakeCurrent(%d, %d) failed\n", (int)baseDC, (int)baseRC); return false; } diff --git a/zone.c b/zone.c index 6999200a..fc75486b 100644 --- a/zone.c +++ b/zone.c @@ -38,7 +38,7 @@ void *_Mem_Alloc(mempool_t *pool, size_t size, const char *filename, int filelin if (pool == NULL) Sys_Error("Mem_Alloc: pool == NULL (alloc at %s:%i)", filename, fileline); if (developer.integer && developer_memory.integer) - Con_Printf("Mem_Alloc: pool %s, file %s:%i, size %i bytes\n", pool->name, filename, fileline, size); + Con_Printf("Mem_Alloc: pool %s, file %s:%i, size %i bytes\n", pool->name, filename, fileline, (int)size); if (developer.integer && developer_memorydebug.integer) _Mem_CheckSentinelsGlobal(filename, fileline); pool->totalsize += size; @@ -139,7 +139,7 @@ static void _Mem_FreeBlock(memheader_t *mem, const char *filename, int fileline) Sys_Error("Mem_Free: trashed header sentinel 2 (alloc at %s:%i, free at %s:%i)", mem->filename, mem->fileline, filename, fileline); pool = mem->pool; if (developer.integer && developer_memory.integer) - Con_Printf("Mem_Free: pool %s, alloc %s:%i, free %s:%i, size %i bytes\n", pool->name, mem->filename, mem->fileline, filename, fileline, mem->size); + Con_Printf("Mem_Free: pool %s, alloc %s:%i, free %s:%i, size %i bytes\n", pool->name, mem->filename, mem->fileline, filename, fileline, (int)(mem->size)); // unlink memheader from doubly linked list if ((mem->prev ? mem->prev->next != mem : pool->chain != mem) || (mem->next && mem->next->prev != mem)) Sys_Error("Mem_Free: not allocated or double freed (free at %s:%i)", filename, fileline); -- 2.39.2