printf arg checking. unfortunatly, due to a bug in gcc, no checking on the

function pointers, but all the other printf style functions are checked.

Also, use gcc_attr.h from qf so quake2 will compile with lame compilers
This commit is contained in:
Bill Currie 2002-01-12 03:23:32 +00:00
parent dd282fb15f
commit 45955b16f2
16 changed files with 56 additions and 30 deletions

View file

@ -332,7 +332,7 @@ void CL_Setenv_f( void )
} }
else else
{ {
Com_Printf( "%s undefined\n", Cmd_Argv(1), env ); Com_Printf( "%s undefined\n", Cmd_Argv(1));
} }
} }
} }
@ -504,7 +504,7 @@ void CL_Connect_f (void)
if (Com_ServerState ()) if (Com_ServerState ())
{ // if running a local server, kill it and reissue { // if running a local server, kill it and reissue
SV_Shutdown (va("Server quit\n", msg), false); SV_Shutdown ("Server quit\n", false);
} }
else else
{ {

View file

@ -458,7 +458,7 @@ void CL_LoadClientinfo (clientinfo_t *ci, char *s)
// it, so default to grunt // it, so default to grunt
if (!ci->skin) { if (!ci->skin) {
// see if the skin exists for the male model // see if the skin exists for the male model
Com_sprintf (skin_filename, sizeof(skin_filename), "players/%s/grunt.pcx", model_name, skin_name); Com_sprintf (skin_filename, sizeof(skin_filename), "players/%s/grunt.pcx", model_name);
ci->skin = re.RegisterSkin (skin_filename); ci->skin = re.RegisterSkin (skin_filename);
} }

View file

@ -310,7 +310,7 @@ void CL_PrepRefresh (void)
Com_Printf (" \r"); Com_Printf (" \r");
} }
Com_Printf ("images\r", i); Com_Printf ("images\r");
SCR_UpdateScreen (); SCR_UpdateScreen ();
for (i=1 ; i<MAX_IMAGES && cl.configstrings[CS_IMAGES+i][0] ; i++) for (i=1 ; i<MAX_IMAGES && cl.configstrings[CS_IMAGES+i][0] ; i++)
{ {
@ -333,7 +333,7 @@ void CL_PrepRefresh (void)
CL_LoadClientinfo (&cl.baseclientinfo, "unnamed\\male/grunt"); CL_LoadClientinfo (&cl.baseclientinfo, "unnamed\\male/grunt");
// set sky textures and speed // set sky textures and speed
Com_Printf ("sky\r", i); Com_Printf ("sky\r");
SCR_UpdateScreen (); SCR_UpdateScreen ();
rotate = atof (cl.configstrings[CS_SKYROTATE]); rotate = atof (cl.configstrings[CS_SKYROTATE]);
sscanf (cl.configstrings[CS_SKYAXIS], "%f %f %f", sscanf (cl.configstrings[CS_SKYAXIS], "%f %f %f",

View file

@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define __REF_H #define __REF_H
#include "../qcommon/qcommon.h" #include "../qcommon/qcommon.h"
#include "../qcommon/gcc_attr.h"
#define MAX_DLIGHTS 32 #define MAX_DLIGHTS 32
#define MAX_ENTITIES 128 #define MAX_ENTITIES 128
@ -190,6 +191,7 @@ typedef struct
// //
typedef struct typedef struct
{ {
//void (*Sys_Error) (int err_level, char *str, ...) __attribute__((noreturn, format(printf,2,3)));
void (*Sys_Error) (int err_level, char *str, ...) __attribute__((noreturn)); void (*Sys_Error) (int err_level, char *str, ...) __attribute__((noreturn));
void (*Cmd_AddCommand) (char *name, void(*cmd)(void)); void (*Cmd_AddCommand) (char *name, void(*cmd)(void));
@ -198,6 +200,7 @@ typedef struct
char *(*Cmd_Argv) (int i); char *(*Cmd_Argv) (int i);
void (*Cmd_ExecuteText) (int exec_when, char *text); void (*Cmd_ExecuteText) (int exec_when, char *text);
//void (*Con_Printf) (int print_level, char *str, ...) __attribute__((format(printf,2,3)));
void (*Con_Printf) (int print_level, char *str, ...); void (*Con_Printf) (int print_level, char *str, ...);
// files will be memory mapped read only // files will be memory mapped read only

View file

@ -103,7 +103,7 @@ void S_SoundInfo_f(void)
Com_Printf("%5d samplebits\n", dma.samplebits); Com_Printf("%5d samplebits\n", dma.samplebits);
Com_Printf("%5d submission_chunk\n", dma.submission_chunk); Com_Printf("%5d submission_chunk\n", dma.submission_chunk);
Com_Printf("%5d speed\n", dma.speed); Com_Printf("%5d speed\n", dma.speed);
Com_Printf("0x%x dma buffer\n", dma.buffer); Com_Printf("0x%lx dma buffer\n", (unsigned long)dma.buffer);
} }

View file

@ -214,9 +214,9 @@ void InitGame (void)
// items // items
InitItems (); InitItems ();
Com_sprintf (game.helpmessage1, sizeof(game.helpmessage1), ""); game.helpmessage1[0] = 0;
Com_sprintf (game.helpmessage2, sizeof(game.helpmessage2), ""); game.helpmessage2[0] = 0;
// initialize all entities for this game // initialize all entities for this game
game.maxentities = maxentities->value; game.maxentities = maxentities->value;

View file

@ -17,6 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "../qcommon/gcc_attr.h"
// game.h -- game dll information visible to server // game.h -- game dll information visible to server
@ -109,10 +110,17 @@ struct edict_s
typedef struct typedef struct
{ {
// special messages // special messages
#if 0
void (*bprintf) (int printlevel, char *fmt, ...) __attribute__((format(printf,2,3)));
void (*dprintf) (char *fmt, ...) __attribute__((format(printf,1,2)));
void (*cprintf) (edict_t *ent, int printlevel, char *fmt, ...) __attribute__((format(printf,3,4)));
void (*centerprintf) (edict_t *ent, char *fmt, ...) __attribute__((format(printf,2,3)));
#else
void (*bprintf) (int printlevel, char *fmt, ...); void (*bprintf) (int printlevel, char *fmt, ...);
void (*dprintf) (char *fmt, ...); void (*dprintf) (char *fmt, ...);
void (*cprintf) (edict_t *ent, int printlevel, char *fmt, ...); void (*cprintf) (edict_t *ent, int printlevel, char *fmt, ...);
void (*centerprintf) (edict_t *ent, char *fmt, ...); void (*centerprintf) (edict_t *ent, char *fmt, ...);
#endif
void (*sound) (edict_t *ent, int channel, int soundindex, float volume, float attenuation, float timeofs); void (*sound) (edict_t *ent, int channel, int soundindex, float volume, float attenuation, float timeofs);
void (*positioned_sound) (vec3_t origin, edict_t *ent, int channel, int soundinedex, float volume, float attenuation, float timeofs); void (*positioned_sound) (vec3_t origin, edict_t *ent, int channel, int soundinedex, float volume, float attenuation, float timeofs);
@ -122,6 +130,7 @@ typedef struct
// they connect, and changes are sent to all connected clients. // they connect, and changes are sent to all connected clients.
void (*configstring) (int num, char *string); void (*configstring) (int num, char *string);
//void (*error) (char *fmt, ...) __attribute__((noreturn, format(printf,1,2)));
void (*error) (char *fmt, ...) __attribute__((noreturn)); void (*error) (char *fmt, ...) __attribute__((noreturn));
// the *index functions create configstrings and some internal server state // the *index functions create configstrings and some internal server state

View file

@ -17,6 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "../qcommon/gcc_attr.h"
// q_shared.h -- included first by ALL program modules // q_shared.h -- included first by ALL program modules
@ -218,7 +219,7 @@ void COM_DefaultExtension (char *path, char *extension);
char *COM_Parse (char **data_p); char *COM_Parse (char **data_p);
// data is an in/out parm, returns a parsed out token // data is an in/out parm, returns a parsed out token
void Com_sprintf (char *dest, int size, char *fmt, ...); void Com_sprintf (char *dest, int size, char *fmt, ...) __attribute__((format(printf,3,4)));
void Com_PageInMemory (byte *buffer, int size); void Com_PageInMemory (byte *buffer, int size);
@ -239,7 +240,7 @@ float BigFloat (float l);
float LittleFloat (float l); float LittleFloat (float l);
void Swap_Init (void); void Swap_Init (void);
char *va(char *format, ...); char *va(char *format, ...) __attribute__((format(printf,1,2)));
//============================================= //=============================================
@ -290,8 +291,8 @@ void Sys_FindClose (void);
// this is only here so the functions in q_shared.c and q_shwin.c can link // this is only here so the functions in q_shared.c and q_shwin.c can link
void Sys_Error (char *error, ...) __attribute__((noreturn)); void Sys_Error (char *error, ...) __attribute__((noreturn, format(printf,1,2)));
void Com_Printf (char *msg, ...); void Com_Printf (char *msg, ...) __attribute__((format(printf,1,2)));
/* /*

View file

@ -206,9 +206,9 @@ void InitGame (void)
// items // items
InitItems (); InitItems ();
Com_sprintf (game.helpmessage1, sizeof(game.helpmessage1), ""); game.helpmessage1[0] = 0;
Com_sprintf (game.helpmessage2, sizeof(game.helpmessage2), ""); game.helpmessage2[0] = 0;
// initialize all entities for this game // initialize all entities for this game
game.maxentities = maxentities->value; game.maxentities = maxentities->value;

View file

@ -17,6 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "../qcommon/gcc_attr.h"
// game.h -- game dll information visible to server // game.h -- game dll information visible to server
@ -102,10 +103,17 @@ struct edict_s
typedef struct typedef struct
{ {
// special messages // special messages
#if 0
void (*bprintf) (int printlevel, char *fmt, ...) __attribute__((format(printf,2,3)));
void (*dprintf) (char *fmt, ...) __attribute__((format(printf,1,2)));
void (*cprintf) (edict_t *ent, int printlevel, char *fmt, ...) __attribute__((format(printf,3,4)));
void (*centerprintf) (edict_t *ent, char *fmt, ...) __attribute__((format(printf,2,3)));
#else
void (*bprintf) (int printlevel, char *fmt, ...); void (*bprintf) (int printlevel, char *fmt, ...);
void (*dprintf) (char *fmt, ...); void (*dprintf) (char *fmt, ...);
void (*cprintf) (edict_t *ent, int printlevel, char *fmt, ...); void (*cprintf) (edict_t *ent, int printlevel, char *fmt, ...);
void (*centerprintf) (edict_t *ent, char *fmt, ...); void (*centerprintf) (edict_t *ent, char *fmt, ...);
#endif
void (*sound) (edict_t *ent, int channel, int soundindex, float volume, float attenuation, float timeofs); void (*sound) (edict_t *ent, int channel, int soundindex, float volume, float attenuation, float timeofs);
void (*positioned_sound) (vec3_t origin, edict_t *ent, int channel, int soundinedex, float volume, float attenuation, float timeofs); void (*positioned_sound) (vec3_t origin, edict_t *ent, int channel, int soundinedex, float volume, float attenuation, float timeofs);
@ -115,6 +123,7 @@ typedef struct
// they connect, and changes are sent to all connected clients. // they connect, and changes are sent to all connected clients.
void (*configstring) (int num, char *string); void (*configstring) (int num, char *string);
//void (*error) (char *fmt, ...) __attribute__((noreturn, format(printf,1,2)));
void (*error) (char *fmt, ...) __attribute__((noreturn)); void (*error) (char *fmt, ...) __attribute__((noreturn));
// the *index functions create configstrings and some internal server state // the *index functions create configstrings and some internal server state

View file

@ -17,6 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "../qcommon/gcc_attr.h"
// q_shared.h -- included first by ALL program modules // q_shared.h -- included first by ALL program modules
@ -218,7 +219,7 @@ void COM_DefaultExtension (char *path, char *extension);
char *COM_Parse (char **data_p); char *COM_Parse (char **data_p);
// data is an in/out parm, returns a parsed out token // data is an in/out parm, returns a parsed out token
void Com_sprintf (char *dest, int size, char *fmt, ...); void Com_sprintf (char *dest, int size, char *fmt, ...) __attribute__((format(printf,3,4)));
void Com_PageInMemory (byte *buffer, int size); void Com_PageInMemory (byte *buffer, int size);
@ -239,7 +240,7 @@ float BigFloat (float l);
float LittleFloat (float l); float LittleFloat (float l);
void Swap_Init (void); void Swap_Init (void);
char *va(char *format, ...); char *va(char *format, ...) __attribute__((format(printf,1,2)));
//============================================= //=============================================
@ -290,8 +291,8 @@ void Sys_FindClose (void);
// this is only here so the functions in q_shared.c and q_shwin.c can link // this is only here so the functions in q_shared.c and q_shwin.c can link
void Sys_Error (char *error, ...) __attribute__((noreturn)); void Sys_Error (char *error, ...) __attribute__((noreturn, format(printf,1,2)));
void Com_Printf (char *msg, ...); void Com_Printf (char *msg, ...) __attribute__((format(printf,1,2)));
/* /*

View file

@ -1028,7 +1028,7 @@ static qboolean SWimp_InitGraphics( qboolean fullscreen )
else if (num_visuals == 0) else if (num_visuals == 0)
{ {
if (template_mask == VisualIDMask) if (template_mask == VisualIDMask)
Sys_Error("VID: Bad visual id %d\n", template.visualid); Sys_Error("VID: Bad visual id %ld\n", template.visualid);
else else
Sys_Error("VID: No visuals at depth %d\n", template.depth); Sys_Error("VID: No visuals at depth %d\n", template.depth);
} }

View file

@ -17,6 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "../qcommon/gcc_attr.h"
// qcommon.h -- definitions common between client and server, but not game.dll // qcommon.h -- definitions common between client and server, but not game.dll
@ -607,7 +608,7 @@ void Netchan_Setup (netsrc_t sock, netchan_t *chan, netadr_t adr, int qport);
qboolean Netchan_NeedReliable (netchan_t *chan); qboolean Netchan_NeedReliable (netchan_t *chan);
void Netchan_Transmit (netchan_t *chan, int length, byte *data); void Netchan_Transmit (netchan_t *chan, int length, byte *data);
void Netchan_OutOfBand (int net_socket, netadr_t adr, int length, byte *data); void Netchan_OutOfBand (int net_socket, netadr_t adr, int length, byte *data);
void Netchan_OutOfBandPrint (int net_socket, netadr_t adr, char *format, ...); void Netchan_OutOfBandPrint (int net_socket, netadr_t adr, char *format, ...) __attribute__((format(printf,3,4)));
qboolean Netchan_Process (netchan_t *chan, sizebuf_t *msg); qboolean Netchan_Process (netchan_t *chan, sizebuf_t *msg);
qboolean Netchan_CanReliable (netchan_t *chan); qboolean Netchan_CanReliable (netchan_t *chan);
@ -736,10 +737,10 @@ MISC
void Com_BeginRedirect (int target, char *buffer, int buffersize, void (*flush)); void Com_BeginRedirect (int target, char *buffer, int buffersize, void (*flush));
void Com_EndRedirect (void); void Com_EndRedirect (void);
void Com_Printf (char *fmt, ...); void Com_Printf (char *fmt, ...) __attribute__((format(printf,1,2)));
void Com_DPrintf (char *fmt, ...); void Com_DPrintf (char *fmt, ...) __attribute__((format(printf,1,2)));
void Com_MDPrintf (char *fmt, ...); void Com_MDPrintf (char *fmt, ...) __attribute__((format(printf,1,2)));
void Com_Error (int code, char *fmt, ...) __attribute__((noreturn)); void Com_Error (int code, char *fmt, ...) __attribute__((noreturn, format(printf,2,3)));
void Com_Quit (void); void Com_Quit (void);
int Com_ServerState (void); // this should have just been a cvar... int Com_ServerState (void); // this should have just been a cvar...
@ -800,7 +801,7 @@ void *Sys_GetGameAPI (void *parms);
char *Sys_ConsoleInput (void); char *Sys_ConsoleInput (void);
void Sys_ConsoleOutput (char *string); void Sys_ConsoleOutput (char *string);
void Sys_SendKeyEvents (void); void Sys_SendKeyEvents (void);
void Sys_Error (char *error, ...) __attribute__((noreturn)); void Sys_Error (char *error, ...) __attribute__((noreturn, format(printf,1,2)));
void Sys_Quit (void); void Sys_Quit (void);
char *Sys_GetClipboardData( void ); char *Sys_GetClipboardData( void );
void Sys_CopyProtect (void); void Sys_CopyProtect (void);

View file

@ -31,6 +31,7 @@
#define __quakeio_h #define __quakeio_h
#include <stdio.h> #include <stdio.h>
#include "../qcommon/gcc_attr.h"
typedef struct QFile_s QFile; typedef struct QFile_s QFile;

View file

@ -22,6 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//define PARANOID // speed sapping error checking //define PARANOID // speed sapping error checking
#include "../qcommon/gcc_attr.h"
#include "../qcommon/qcommon.h" #include "../qcommon/qcommon.h"
#include "../game/game.h" #include "../game/game.h"
@ -253,9 +254,9 @@ void SV_Multicast (vec3_t origin, multicast_t to);
void SV_StartSound (vec3_t origin, edict_t *entity, int channel, void SV_StartSound (vec3_t origin, edict_t *entity, int channel,
int soundindex, float volume, int soundindex, float volume,
float attenuation, float timeofs); float attenuation, float timeofs);
void SV_ClientPrintf (client_t *cl, int level, char *fmt, ...); void SV_ClientPrintf (client_t *cl, int level, char *fmt, ...) __attribute__((format(printf,3,4)));
void SV_BroadcastPrintf (int level, char *fmt, ...); void SV_BroadcastPrintf (int level, char *fmt, ...) __attribute__((format(printf,2,3)));
void SV_BroadcastCommand (char *fmt, ...); void SV_BroadcastCommand (char *fmt, ...) __attribute__((format(printf,1,2)));
// //
// sv_user.c // sv_user.c
@ -277,7 +278,7 @@ void SV_RecordDemoMessage (void);
void SV_BuildClientFrame (client_t *client); void SV_BuildClientFrame (client_t *client);
void SV_Error (char *error, ...); void SV_Error (char *error, ...) __attribute__((format(printf,1,2)));
// //
// sv_game.c // sv_game.c

View file

@ -185,7 +185,7 @@ void SVC_Info (void)
version = atoi (Cmd_Argv(1)); version = atoi (Cmd_Argv(1));
if (version != PROTOCOL_VERSION) if (version != PROTOCOL_VERSION)
Com_sprintf (string, sizeof(string), "%s: wrong version\n", hostname->string, sizeof(string)); Com_sprintf (string, sizeof(string), "%s: wrong version\n", hostname->string);
else else
{ {
count = 0; count = 0;