mirror of
https://git.code.sf.net/p/quake/newtree
synced 2025-05-31 01:00:53 +00:00
add format checking to our printf style functions and correct the consequences
of this.
This commit is contained in:
parent
811744c473
commit
ee3f88d57d
11 changed files with 69 additions and 23 deletions
|
@ -35,6 +35,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "cvar.h"
|
#include "cvar.h"
|
||||||
|
#include "gcc_attr.h"
|
||||||
|
|
||||||
/* The host system specifies the base of the directory tree, the
|
/* The host system specifies the base of the directory tree, the
|
||||||
command line parms passed to the program, and the amount of memory
|
command line parms passed to the program, and the amount of memory
|
||||||
|
@ -61,7 +62,7 @@ extern qboolean host_initialized; /* True if into command execution. */
|
||||||
extern double realtime; /* Not bounded in any way, changed at
|
extern double realtime; /* Not bounded in any way, changed at
|
||||||
start of every frame, never reset */
|
start of every frame, never reset */
|
||||||
|
|
||||||
char *va(char *format, ...);
|
char *va(char *format, ...) __attribute__((format(printf,1,2)));
|
||||||
// does a varargs printf into a temp buffer
|
// does a varargs printf into a temp buffer
|
||||||
|
|
||||||
#endif // _COMMDEF_H
|
#endif // _COMMDEF_H
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "qtypes.h"
|
#include "qtypes.h"
|
||||||
|
#include "gcc_attr.h"
|
||||||
|
|
||||||
#define CON_TEXTSIZE 16384
|
#define CON_TEXTSIZE 16384
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -61,9 +62,9 @@ void Con_CheckResize (void);
|
||||||
void Con_Init (void);
|
void Con_Init (void);
|
||||||
void Con_DrawConsole (int lines);
|
void Con_DrawConsole (int lines);
|
||||||
void Con_Print (char *txt);
|
void Con_Print (char *txt);
|
||||||
void Con_Printf (char *fmt, ...);
|
void Con_Printf (char *fmt, ...) __attribute__((format(printf,1,2)));
|
||||||
void Con_DPrintf (char *fmt, ...);
|
void Con_DPrintf (char *fmt, ...) __attribute__((format(printf,1,2)));
|
||||||
void Con_SafePrintf (char *fmt, ...);
|
void Con_SafePrintf (char *fmt, ...) __attribute__((format(printf,1,2)));
|
||||||
void Con_Clear_f (void);
|
void Con_Clear_f (void);
|
||||||
void Con_DrawNotify (void);
|
void Con_DrawNotify (void);
|
||||||
void Con_ClearNotify (void);
|
void Con_ClearNotify (void);
|
||||||
|
|
36
include/gcc_attr.h
Normal file
36
include/gcc_attr.h
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
gcc_attr.h
|
||||||
|
|
||||||
|
GCC __attribute__ protection for lame compilers.
|
||||||
|
|
||||||
|
Copyright (C) 1996-1997 Id Software, Inc.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to:
|
||||||
|
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
59 Temple Place - Suite 330
|
||||||
|
Boston, MA 02111-1307, USA
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _GCC_ATTR_H
|
||||||
|
#define _GCC_ATTR_H
|
||||||
|
|
||||||
|
#ifndef __GNUC__
|
||||||
|
#define __attribute__(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // _GCC_ATTR_H
|
|
@ -29,6 +29,7 @@
|
||||||
#ifndef _NET_H
|
#ifndef _NET_H
|
||||||
#define _NET_H
|
#define _NET_H
|
||||||
|
|
||||||
|
#include "gcc_attr.h"
|
||||||
#include "sizebuf.h"
|
#include "sizebuf.h"
|
||||||
#include "cvar.h"
|
#include "cvar.h"
|
||||||
|
|
||||||
|
@ -116,7 +117,7 @@ extern int net_drop; // packets dropped before this one
|
||||||
void Netchan_Init (void);
|
void Netchan_Init (void);
|
||||||
void Netchan_Transmit (netchan_t *chan, int length, byte *data);
|
void Netchan_Transmit (netchan_t *chan, int length, byte *data);
|
||||||
void Netchan_OutOfBand (netadr_t adr, int length, byte *data);
|
void Netchan_OutOfBand (netadr_t adr, int length, byte *data);
|
||||||
void Netchan_OutOfBandPrint (netadr_t adr, char *format, ...);
|
void Netchan_OutOfBandPrint (netadr_t adr, char *format, ...) __attribute__((format(printf,2,3)));
|
||||||
qboolean Netchan_Process (netchan_t *chan);
|
qboolean Netchan_Process (netchan_t *chan);
|
||||||
void Netchan_Setup (netchan_t *chan, netadr_t adr, int qport);
|
void Netchan_Setup (netchan_t *chan, netadr_t adr, int qport);
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#ifndef _PROGS_H
|
#ifndef _PROGS_H
|
||||||
#define _PROGS_H
|
#define _PROGS_H
|
||||||
|
|
||||||
|
#include "gcc_attr.h"
|
||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
#include "pr_comp.h" // defs shared with qcc
|
#include "pr_comp.h" // defs shared with qcc
|
||||||
#include "progdefs.h" // generated by program cdefs
|
#include "progdefs.h" // generated by program cdefs
|
||||||
|
@ -140,7 +141,7 @@ extern func_t SpectatorConnect;
|
||||||
extern func_t SpectatorThink;
|
extern func_t SpectatorThink;
|
||||||
extern func_t SpectatorDisconnect;
|
extern func_t SpectatorDisconnect;
|
||||||
|
|
||||||
void PR_RunError (char *error, ...);
|
void PR_RunError (char *error, ...) __attribute__((format(printf,1,2)));
|
||||||
|
|
||||||
void ED_PrintEdicts (void);
|
void ED_PrintEdicts (void);
|
||||||
void ED_PrintNum (int ent);
|
void ED_PrintNum (int ent);
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
#ifndef _QUAKEDEF_H
|
#ifndef _QUAKEDEF_H
|
||||||
#define _QUAKEDEF_H
|
#define _QUAKEDEF_H
|
||||||
|
|
||||||
|
#include "gcc_attr.h"
|
||||||
|
|
||||||
#define QUAKE_GAME // as opposed to utilities
|
#define QUAKE_GAME // as opposed to utilities
|
||||||
|
|
||||||
//define PARANOID // speed sapping error checking
|
//define PARANOID // speed sapping error checking
|
||||||
|
@ -71,12 +73,12 @@ void Host_ServerFrame (void);
|
||||||
void Host_InitCommands (void);
|
void Host_InitCommands (void);
|
||||||
void Host_Init (quakeparms_t *parms);
|
void Host_Init (quakeparms_t *parms);
|
||||||
void Host_Shutdown(void);
|
void Host_Shutdown(void);
|
||||||
void Host_Error (char *error, ...);
|
void Host_Error (char *error, ...) __attribute__((format(printf,1,2)));
|
||||||
void Host_EndGame (char *message, ...);
|
void Host_EndGame (char *message, ...) __attribute__((format(printf,1,2)));
|
||||||
qboolean Host_SimulationTime(float time);
|
qboolean Host_SimulationTime(float time);
|
||||||
void Host_Frame (float time);
|
void Host_Frame (float time);
|
||||||
void Host_Quit_f (void);
|
void Host_Quit_f (void);
|
||||||
void Host_ClientCommands (char *fmt, ...);
|
void Host_ClientCommands (char *fmt, ...) __attribute__((format(printf,1,2)));
|
||||||
void Host_ShutdownServer (qboolean crash);
|
void Host_ShutdownServer (qboolean crash);
|
||||||
|
|
||||||
#endif // _QUAKEDEH_H
|
#endif // _QUAKEDEH_H
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#ifndef _QUAKEIO_H
|
#ifndef _QUAKEIO_H
|
||||||
#define _QUAKEIO_H
|
#define _QUAKEIO_H
|
||||||
|
|
||||||
|
#include "gcc_attr.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
@ -41,7 +42,7 @@ FILE *Qdopen(int fd, const char *mode);
|
||||||
void Qclose(FILE *file);
|
void Qclose(FILE *file);
|
||||||
int Qread(FILE *file, void *buf, int count);
|
int Qread(FILE *file, void *buf, int count);
|
||||||
int Qwrite(FILE *file, void *buf, int count);
|
int Qwrite(FILE *file, void *buf, int count);
|
||||||
int Qprintf(FILE *file, const char *fmt, ...);
|
int Qprintf(FILE *file, const char *fmt, ...) __attribute__((format(printf,2,3)));
|
||||||
char *Qgets(FILE *file, char *buf, int count);
|
char *Qgets(FILE *file, char *buf, int count);
|
||||||
int Qgetc(FILE *file);
|
int Qgetc(FILE *file);
|
||||||
int Qputc(FILE *file, int c);
|
int Qputc(FILE *file, int c);
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#ifndef _SERVER_H
|
#ifndef _SERVER_H
|
||||||
#define _SERVER_H
|
#define _SERVER_H
|
||||||
|
|
||||||
|
#include "gcc_attr.h"
|
||||||
#include "commdef.h"
|
#include "commdef.h"
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
#include "cvar.h"
|
#include "cvar.h"
|
||||||
|
@ -369,11 +370,11 @@ extern double sv_frametime;
|
||||||
//===========================================================
|
//===========================================================
|
||||||
// FIXME: declare exported functions in their own relevant .h
|
// FIXME: declare exported functions in their own relevant .h
|
||||||
|
|
||||||
void SV_Error (char *error, ...);
|
void SV_Error (char *error, ...) __attribute__((format(printf,1,2)));
|
||||||
void SV_Init (quakeparms_t *parms);
|
void SV_Init (quakeparms_t *parms);
|
||||||
|
|
||||||
void Con_Printf (char *fmt, ...);
|
void Con_Printf (char *fmt, ...) __attribute__((format(printf,1,2)));
|
||||||
void Con_DPrintf (char *fmt, ...);
|
void Con_DPrintf (char *fmt, ...) __attribute__((format(printf,1,2)));
|
||||||
|
|
||||||
//
|
//
|
||||||
// sv_main.c
|
// sv_main.c
|
||||||
|
@ -436,9 +437,9 @@ void SV_SendClientMessages (void);
|
||||||
void SV_Multicast (vec3_t origin, int to);
|
void SV_Multicast (vec3_t origin, int to);
|
||||||
void SV_StartSound (edict_t *entity, int channel, char *sample, int volume,
|
void SV_StartSound (edict_t *entity, int channel, char *sample, int volume,
|
||||||
float attenuation);
|
float attenuation);
|
||||||
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)));
|
||||||
void SV_SendMessagesToAll (void);
|
void SV_SendMessagesToAll (void);
|
||||||
void SV_FindModelNumbers (void);
|
void SV_FindModelNumbers (void);
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
#ifndef _SYS_H
|
#ifndef _SYS_H
|
||||||
#define _SYS_H
|
#define _SYS_H
|
||||||
|
|
||||||
|
#include "gcc_attr.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// file IO
|
// file IO
|
||||||
//
|
//
|
||||||
|
@ -54,12 +56,12 @@ void Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length);
|
||||||
//
|
//
|
||||||
// system IO
|
// system IO
|
||||||
//
|
//
|
||||||
void Sys_DebugLog(char *file, char *fmt, ...);
|
void Sys_DebugLog(char *file, char *fmt, ...) __attribute__((format(printf,2,3)));
|
||||||
|
|
||||||
void Sys_Error (char *error, ...);
|
void Sys_Error (char *error, ...) __attribute__((format(printf,1,2)));
|
||||||
// an error will cause the entire program to exit
|
// an error will cause the entire program to exit
|
||||||
|
|
||||||
void Sys_Printf (char *fmt, ...);
|
void Sys_Printf (char *fmt, ...) __attribute__((format(printf,1,2)));
|
||||||
// send text to the console
|
// send text to the console
|
||||||
|
|
||||||
void Sys_Quit (void);
|
void Sys_Quit (void);
|
||||||
|
@ -76,7 +78,7 @@ void Sys_LowFPPrecision (void);
|
||||||
void Sys_HighFPPrecision (void);
|
void Sys_HighFPPrecision (void);
|
||||||
void Sys_SetFPCW (void);
|
void Sys_SetFPCW (void);
|
||||||
|
|
||||||
void Sys_Printf (char *fmt, ...);
|
void Sys_Printf (char *fmt, ...) __attribute__((format(printf,1,2)));
|
||||||
// send text to the console
|
// send text to the console
|
||||||
|
|
||||||
void Sys_Init (void);
|
void Sys_Init (void);
|
||||||
|
|
|
@ -1258,13 +1258,13 @@ void CL_ParseServerMessage (void)
|
||||||
for (i=0 ; i<3 ; i++)
|
for (i=0 ; i<3 ; i++)
|
||||||
{
|
{
|
||||||
cl.simorg[i] = MSG_ReadCoord ();
|
cl.simorg[i] = MSG_ReadCoord ();
|
||||||
Con_DPrintf ("%i ", cl.simorg[i]);
|
Con_DPrintf ("%f ", cl.simorg[i]);
|
||||||
}
|
}
|
||||||
Con_DPrintf ("\nintermission simangles: ");
|
Con_DPrintf ("\nintermission simangles: ");
|
||||||
for (i=0 ; i<3 ; i++)
|
for (i=0 ; i<3 ; i++)
|
||||||
{
|
{
|
||||||
cl.simangles[i] = MSG_ReadAngle ();
|
cl.simangles[i] = MSG_ReadAngle ();
|
||||||
Con_DPrintf ("%i ", cl.simangles[i]);
|
Con_DPrintf ("%f ", cl.simangles[i]);
|
||||||
}
|
}
|
||||||
Con_DPrintf ("\n");
|
Con_DPrintf ("\n");
|
||||||
VectorCopy (vec3_origin, cl.simvel);
|
VectorCopy (vec3_origin, cl.simvel);
|
||||||
|
|
|
@ -557,7 +557,7 @@ void VID_Init (unsigned char *palette)
|
||||||
printf(" -visualid %d\n", (int)(x_visinfo[i].visualid));
|
printf(" -visualid %d\n", (int)(x_visinfo[i].visualid));
|
||||||
} 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",
|
Sys_Error("VID: Bad visual id %ld\n",
|
||||||
template.visualid);
|
template.visualid);
|
||||||
} else {
|
} else {
|
||||||
Sys_Error("VID: No visuals at depth %d\n",
|
Sys_Error("VID: No visuals at depth %d\n",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue