]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
patch from div0 that enables printf format warnings in gcc
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 14 Jan 2007 10:19:20 +0000 (10:19 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 14 Jan 2007 10:19:20 +0000 (10:19 +0000)
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

32 files changed:
cd_win.c
cl_main.c
cl_parse.c
common.h
console.c
console.h
csprogs.c
fs.c
fs.h
gl_backend.c
gl_textures.c
image_png.c
menu.c
model_alias.c
model_brush.c
model_shared.c
mvm_cmds.c
netconn.c
progsvm.h
prvm_cmds.c
prvm_edict.c
prvm_execprogram.h
quakedef.h
r_shadow.c
r_sky.c
server.h
snd_mix.c
snd_win.c
sys.h
vid_agl.c
vid_wgl.c
zone.c

index 5b475496260eb5a1215c1e2079fe60c61a8bb601..495fe02091dd97e6cc5ac341e26868db9940a87e 100644 (file)
--- 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;
        }
index ad44adc4861c887e1b588adbf766cf45421f97ee..01a98318bf7c90eddfccf69d222013fe409539c4 100644 (file)
--- 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);
index 3cb9084f6a959bdf0a1a0dfc58228e36c56861e6..3cc5820ad9d571f31b8d89c41c1a5a18ebc4bb32 100644 (file)
@@ -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]));
                }
 
index 64eecf312f9d741b4de04441bd1df14940754b9d..816a8fa96be90f3e20818222d94762a9ffc394c8 100644 (file)
--- 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)
index f2226351c3fd3cb69a655902cc42f299eed73cc8..03671837fbdabba91f1e363d7bcfdd4e6ade0928 100644 (file)
--- 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
index 4b8048c922554c2e19b6c2338986601764b59ff4..1849f670dc6f002b85956a9a15e2f6696d10524c 100644 (file)
--- 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
 
index 1243120623aae26ab08433bc38a288a1c311b20b..735adbb27ce5b59c07f4b65e70da28cb902f4cb2 100644 (file)
--- 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 89f0086c55c61fd4bd016417dd2be874b15acabc..8bf3d1c56d905387eaebd12d69ef14752a90cde5 100644 (file)
--- 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 0a9837b1e7903982a682814821c4d3404b1b00b3..11b993242c01f58e3cc1eae9513a7f2761ecf77e 100644 (file)
--- 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);
index 50d37a71186281a54e31e86d51d8d27cbeb21a55..b77e5fb9e1c0604c1eb3e177f07b143f5a2ef56f 100644 (file)
@@ -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
index c3e200fb72e15f2b43f661e4b0dac446efe430ac..8ac8d6cad73cc6a8521ddf252a9621d287591ce4 100644 (file)
@@ -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;
        }
 
index 2f8e76a7cfb3273c6cd931d5ff41097dd442b11d..d9d7a5004f844dfe13aacdfc444493507b56e6d4 100644 (file)
@@ -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 3a0f0d7cd803eb3e2419a13769a0bdef2e3154c1..9f84b008cee1d5684f2c381ed55c0a6a298d99f9 100644 (file)
--- 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;
index 03be060d548c522025f05cb05fb8b0af60217bc2..e3ad40246e8866d83384a3d945ec7874b1312308 100644 (file)
@@ -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);
index 47765028630ca56e2897dcc5073e0a2d4e2b2bbb..75398747848c6a7b10abca21dfda967e9cfe4e59 100644 (file)
@@ -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);
index ad05c4e496f1b6ab1947df4f7270371b56730081..a613449eb92d80caf06203a777c32b61a91c0e5a 100644 (file)
@@ -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);
 }
 
 /*
index b2f0d790922ebb884290615d79acc66d9bb30eef..4984873794662a4157840b2c3a14bfb276f936fb 100644 (file)
@@ -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;
        }
 
index 02f6b5a9e718ed5492b054e786f9b8ba5a8d3c31..ba857902e35540817b143ccdcb4dce52c3bd4483 100755 (executable)
--- 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
index b0ed47bdaf4d7ea7589c226c717360fef8956aa1..7e6250a4f8bfa7a80fb27c9f1898ef0d5dc750c8 100644 (file)
--- 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();
index 20d2dd03ea6988be8461b5026a92d325e02f2cc2..6ff3db2530af56e649e4260d2200934f6aa5e9aa 100644 (file)
@@ -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);
 
index 17c625f10de68dbcf2fc1fa2ee7da97a97123631..5f75aa7b9b37c36f3e42277f64db5968f3bf9241 100644 (file)
@@ -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);
 
index 82f1a97a3c60793fe5d9627fd9a2163b8c1f3719..46ab00608d7db762ac73feb029ad58018ea88d93 100644 (file)
                                        {
                                                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;
                                        {
                                                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;
                                {
                                        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;
 
index e0bdf86000a3c5810a22bca6e2abda1ca8412f9a..f0738de0fc6d3a5c3abb582405a1a4a8d7adc286 100644 (file)
@@ -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 <sys/types.h>
 #include <ctype.h>
@@ -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);
 
index c1a55d4c1d0ee44d5f5373074ddff194ca81068a..69ffabf3ecbb2f061c98c26e2748954017b3f9e4 100644 (file)
@@ -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 bf2c009ebdaf6f3715a82c462c9a6826bbcbaec5..403e4ad75e49011333d842c4842e96d49f09cd3c 100644 (file)
--- 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;
        }
 
index 974374ef137f21713e5a0c3e18cd7ba6d5648fb8..41947092940a0e0a8804978cc23c83468f0c58df 100644 (file)
--- 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);
index 529308b6b76eac329520785838e681eb146818e5..dc2a147402a58b0c06fcacea31ae6d62e7f2b868 100644 (file)
--- 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
        {
index 2a5fa83fee5a5a0c17ef7dcc670b420a8cefa200..06aed2bbe03dcb4f358b4aa67d50853aa6302bb1 100644 (file)
--- 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 278c7982fa8f545e0aacd8b61ae361c821783f8a..d02ae24466a420f09356c85a34a4e380da09cf49 100644 (file)
--- 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);
index de1775c235d5a0b53ff9fe86a5fc75fb0dc411b8..191e7e569eac037270d5ec397d70b1b1c0ced0b2 100644 (file)
--- 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;
index 6c58989553ea21bb69c1709b48b24612e9ae5cfc..d0954d01e4b4550da5611adc2a5bf0aefebb3cb2 100644 (file)
--- 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 6999200ae6589dd7a7277997fb6dcbd11e8f4229..fc75486b45ad79db75b79dd56939bdb3099914b7 100644 (file)
--- 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);