Merge pull request #1060 from devnexen/constify_it

"constifying" where underlying C calls expect compile time constants.
This commit is contained in:
Yamagi 2023-09-16 18:14:17 +02:00 committed by GitHub
commit 73c3afd47e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 63 additions and 63 deletions

View file

@ -65,7 +65,7 @@ extern FILE *logfile;
/* ================================================================ */ /* ================================================================ */
void void
Sys_Error(char *error, ...) Sys_Error(const char *error, ...)
{ {
va_list argptr; va_list argptr;
char string[1024]; char string[1024];

View file

@ -54,7 +54,7 @@ static size_t console_textlen;
/* ================================================================ */ /* ================================================================ */
void void
Sys_Error(char *error, ...) Sys_Error(const char *error, ...)
{ {
va_list argptr; va_list argptr;
char text[1024]; char text[1024];

View file

@ -1961,7 +1961,7 @@ void R_Printf(int level, const char* msg, ...)
* (shared.c, rand.c, flash.c, mem.c/hunk.c) can link * (shared.c, rand.c, flash.c, mem.c/hunk.c) can link
*/ */
void void
Sys_Error(char *error, ...) Sys_Error(const char *error, ...)
{ {
va_list argptr; va_list argptr;
char text[4096]; // MAXPRINTMSG == 4096 char text[4096]; // MAXPRINTMSG == 4096
@ -1974,7 +1974,7 @@ Sys_Error(char *error, ...)
} }
void void
Com_Printf(char *msg, ...) Com_Printf(const char *msg, ...)
{ {
va_list argptr; va_list argptr;
va_start(argptr, msg); va_start(argptr, msg);

View file

@ -2053,7 +2053,7 @@ void R_Printf(int level, const char* msg, ...)
* (shared.c, rand.c, flash.c, mem.c/hunk.c) can link * (shared.c, rand.c, flash.c, mem.c/hunk.c) can link
*/ */
void void
Sys_Error(char *error, ...) Sys_Error(const char *error, ...)
{ {
va_list argptr; va_list argptr;
char text[4096]; // MAXPRINTMSG == 4096 char text[4096]; // MAXPRINTMSG == 4096
@ -2066,7 +2066,7 @@ Sys_Error(char *error, ...)
} }
void void
Com_Printf(char *msg, ...) Com_Printf(const char *msg, ...)
{ {
va_list argptr; va_list argptr;
va_start(argptr, msg); va_start(argptr, msg);

View file

@ -2460,7 +2460,7 @@ SWimp_CreateRender(int width, int height)
// 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 void
Sys_Error (char *error, ...) Sys_Error (const char *error, ...)
{ {
va_list argptr; va_list argptr;
char text[4096]; // MAXPRINTMSG == 4096 char text[4096]; // MAXPRINTMSG == 4096
@ -2473,7 +2473,7 @@ Sys_Error (char *error, ...)
} }
void void
Com_Printf(char *msg, ...) Com_Printf(const char *msg, ...)
{ {
va_list argptr; va_list argptr;
va_start(argptr, msg); va_start(argptr, msg);

View file

@ -216,7 +216,7 @@ typedef struct
typedef struct typedef struct
{ {
YQ2_ATTR_NORETURN_FUNCPTR void (IMPORT *Sys_Error) (int err_level, char *str, ...) PRINTF_ATTR(2, 3); YQ2_ATTR_NORETURN_FUNCPTR void (IMPORT *Sys_Error) (int err_level, const char *str, ...) PRINTF_ATTR(2, 3);
void (IMPORT *Cmd_AddCommand) (char *name, void(*cmd)(void)); void (IMPORT *Cmd_AddCommand) (char *name, void(*cmd)(void));
void (IMPORT *Cmd_RemoveCommand) (char *name); void (IMPORT *Cmd_RemoveCommand) (char *name);
@ -238,9 +238,9 @@ typedef struct
// files should be stored to, ie: "f:\quake\id1" // files should be stored to, ie: "f:\quake\id1"
char *(IMPORT *FS_Gamedir) (void); char *(IMPORT *FS_Gamedir) (void);
cvar_t *(IMPORT *Cvar_Get) (char *name, char *value, int flags); cvar_t *(IMPORT *Cvar_Get) (const char *name, char *value, int flags);
cvar_t *(IMPORT *Cvar_Set) (char *name, char *value); cvar_t *(IMPORT *Cvar_Set) (const char *name, char *value);
void (IMPORT *Cvar_SetValue) (char *name, float value); void (IMPORT *Cvar_SetValue) (const char *name, float value);
qboolean (IMPORT *Vid_GetModeInfo)(int *width, int *height, int mode); qboolean (IMPORT *Vid_GetModeInfo)(int *width, int *height, int mode);
void (IMPORT *Vid_MenuInit)( void ); void (IMPORT *Vid_MenuInit)( void );

View file

@ -136,7 +136,7 @@ memsearch(byte *start, int count, int search)
} }
char * char *
CopyString(char *in) CopyString(const char *in)
{ {
char *out; char *out;

View file

@ -195,7 +195,7 @@ Com_VPrintf(int print_level, const char *fmt, va_list argptr)
* to the apropriate place. * to the apropriate place.
*/ */
void void
Com_Printf(char *fmt, ...) Com_Printf(const char *fmt, ...)
{ {
va_list argptr; va_list argptr;
va_start(argptr, fmt); va_start(argptr, fmt);
@ -207,7 +207,7 @@ Com_Printf(char *fmt, ...)
* A Com_Printf that only shows up if the "developer" cvar is set * A Com_Printf that only shows up if the "developer" cvar is set
*/ */
void void
Com_DPrintf(char *fmt, ...) Com_DPrintf(const char *fmt, ...)
{ {
va_list argptr; va_list argptr;
va_start(argptr, fmt); va_start(argptr, fmt);
@ -220,7 +220,7 @@ Com_DPrintf(char *fmt, ...)
* cvars is set * cvars is set
*/ */
void void
Com_MDPrintf(char *fmt, ...) Com_MDPrintf(const char *fmt, ...)
{ {
va_list argptr; va_list argptr;
char msg[MAXPRINTMSG]; char msg[MAXPRINTMSG];
@ -242,7 +242,7 @@ Com_MDPrintf(char *fmt, ...)
* do the apropriate things. * do the apropriate things.
*/ */
void void
Com_Error(int code, char *fmt, ...) Com_Error(int code, const char *fmt, ...)
{ {
va_list argptr; va_list argptr;
static char msg[MAXPRINTMSG]; static char msg[MAXPRINTMSG];

View file

@ -96,7 +96,7 @@ replacement_t replacements[] = {
static qboolean static qboolean
Cvar_InfoValidate(char *s) Cvar_InfoValidate(const char *s)
{ {
if (strstr(s, "\\")) if (strstr(s, "\\"))
{ {
@ -178,7 +178,7 @@ Cvar_IsFloat(const char *s)
} }
float float
Cvar_VariableValue(char *var_name) Cvar_VariableValue(const char *var_name)
{ {
cvar_t *var; cvar_t *var;
@ -212,7 +212,7 @@ Cvar_VariableString(const char *var_name)
* The flags will be or'ed in if the variable exists. * The flags will be or'ed in if the variable exists.
*/ */
cvar_t * cvar_t *
Cvar_Get(char *var_name, char *var_value, int flags) Cvar_Get(const char *var_name, char *var_value, int flags)
{ {
cvar_t *var; cvar_t *var;
cvar_t **pos; cvar_t **pos;
@ -290,7 +290,7 @@ Cvar_Get(char *var_name, char *var_value, int flags)
} }
cvar_t * cvar_t *
Cvar_Set2(char *var_name, char *value, qboolean force) Cvar_Set2(const char *var_name, char *value, qboolean force)
{ {
cvar_t *var; cvar_t *var;
@ -394,19 +394,19 @@ Cvar_Set2(char *var_name, char *value, qboolean force)
} }
cvar_t * cvar_t *
Cvar_ForceSet(char *var_name, char *value) Cvar_ForceSet(const char *var_name, char *value)
{ {
return Cvar_Set2(var_name, value, true); return Cvar_Set2(var_name, value, true);
} }
cvar_t * cvar_t *
Cvar_Set(char *var_name, char *value) Cvar_Set(const char *var_name, char *value)
{ {
return Cvar_Set2(var_name, value, false); return Cvar_Set2(var_name, value, false);
} }
cvar_t * cvar_t *
Cvar_FullSet(char *var_name, char *value, int flags) Cvar_FullSet(const char *var_name, char *value, int flags)
{ {
cvar_t *var; cvar_t *var;
@ -442,7 +442,7 @@ Cvar_FullSet(char *var_name, char *value, int flags)
} }
void void
Cvar_SetValue(char *var_name, float value) Cvar_SetValue(const char *var_name, float value)
{ {
char val[32]; char val[32];
@ -582,7 +582,7 @@ Cvar_Set_f(void)
* with the archive flag set to true. * with the archive flag set to true.
*/ */
void void
Cvar_WriteVariables(char *path) Cvar_WriteVariables(const char *path)
{ {
cvar_t *var; cvar_t *var;
char buffer[1024]; char buffer[1024];

View file

@ -167,7 +167,7 @@ void COM_AddParm(char *parm);
void COM_Init(void); void COM_Init(void);
void COM_InitArgv(int argc, char **argv); void COM_InitArgv(int argc, char **argv);
char *CopyString(char *in); char *CopyString(const char *in);
/* ================================================================== */ /* ================================================================== */
@ -448,27 +448,27 @@ void Cmd_ForwardToServer(void);
extern cvar_t *cvar_vars; extern cvar_t *cvar_vars;
cvar_t *Cvar_Get(char *var_name, char *value, int flags); cvar_t *Cvar_Get(const char *var_name, char *value, int flags);
/* creates the variable if it doesn't exist, or returns the existing one */ /* creates the variable if it doesn't exist, or returns the existing one */
/* if it exists, the value will not be changed, but flags will be ORed in */ /* if it exists, the value will not be changed, but flags will be ORed in */
/* that allows variables to be unarchived without needing bitflags */ /* that allows variables to be unarchived without needing bitflags */
cvar_t *Cvar_Set(char *var_name, char *value); cvar_t *Cvar_Set(const char *var_name, char *value);
/* will create the variable if it doesn't exist */ /* will create the variable if it doesn't exist */
cvar_t *Cvar_ForceSet(char *var_name, char *value); cvar_t *Cvar_ForceSet(const char *var_name, char *value);
/* will set the variable even if NOSET or LATCH */ /* will set the variable even if NOSET or LATCH */
cvar_t *Cvar_FullSet(char *var_name, char *value, int flags); cvar_t *Cvar_FullSet(const char *var_name, char *value, int flags);
void Cvar_SetValue(char *var_name, float value); void Cvar_SetValue(const char *var_name, float value);
/* expands value to a string and calls Cvar_Set */ /* expands value to a string and calls Cvar_Set */
float Cvar_VariableValue(char *var_name); float Cvar_VariableValue(const char *var_name);
/* returns 0 if not defined or non numeric */ /* returns 0 if not defined or non numeric */
@ -491,7 +491,7 @@ qboolean Cvar_Command(void);
/* command. Returns true if the command was a variable reference that */ /* command. Returns true if the command was a variable reference that */
/* was handled. (print or change) */ /* was handled. (print or change) */
void Cvar_WriteVariables(char *path); void Cvar_WriteVariables(const char *path);
/* appends lines containing "set variable value" for all variables */ /* appends lines containing "set variable value" for all variables */
/* with the archive flag set to true. */ /* with the archive flag set to true. */
@ -741,11 +741,11 @@ void FS_CreatePath(char *path);
void Com_BeginRedirect(int target, char *buffer, int buffersize, void (*flush)(int, char *)); void Com_BeginRedirect(int target, char *buffer, int buffersize, void (*flush)(int, char *));
void Com_EndRedirect(void); void Com_EndRedirect(void);
void Com_Printf(char *fmt, ...) PRINTF_ATTR(1, 2); void Com_Printf(const char *fmt, ...) PRINTF_ATTR(1, 2);
void Com_DPrintf(char *fmt, ...) PRINTF_ATTR(1, 2); void Com_DPrintf(const char *fmt, ...) PRINTF_ATTR(1, 2);
void Com_VPrintf(int print_level, const char *fmt, va_list argptr); /* print_level is PRINT_ALL or PRINT_DEVELOPER */ void Com_VPrintf(int print_level, const char *fmt, va_list argptr); /* print_level is PRINT_ALL or PRINT_DEVELOPER */
void Com_MDPrintf(char *fmt, ...) PRINTF_ATTR(1, 2); void Com_MDPrintf(const char *fmt, ...) PRINTF_ATTR(1, 2);
YQ2_ATTR_NORETURN_FUNCPTR void Com_Error(int code, char *fmt, ...) PRINTF_ATTR(2, 3); YQ2_ATTR_NORETURN_FUNCPTR void Com_Error(int code, const char *fmt, ...) PRINTF_ATTR(2, 3);
YQ2_ATTR_NORETURN void Com_Quit(void); YQ2_ATTR_NORETURN void Com_Quit(void);
/* Ugly work around for unsupported /* Ugly work around for unsupported
@ -838,7 +838,7 @@ void SV_Frame(int usec);
// system.c // system.c
char *Sys_ConsoleInput(void); char *Sys_ConsoleInput(void);
void Sys_ConsoleOutput(char *string); void Sys_ConsoleOutput(char *string);
YQ2_ATTR_NORETURN void Sys_Error(char *error, ...); YQ2_ATTR_NORETURN void Sys_Error(const char *error, ...);
YQ2_ATTR_NORETURN void Sys_Quit(void); YQ2_ATTR_NORETURN void Sys_Quit(void);
void Sys_Init(void); void Sys_Init(void);
char *Sys_GetHomeDir(void); char *Sys_GetHomeDir(void);

View file

@ -406,8 +406,8 @@ char *Sys_FindNext(unsigned musthave, unsigned canthave);
void Sys_FindClose(void); void Sys_FindClose(void);
/* this is only here so the functions in shared source files can link */ /* this is only here so the functions in shared source files can link */
YQ2_ATTR_NORETURN void Sys_Error(char *error, ...); YQ2_ATTR_NORETURN void Sys_Error(const char *error, ...);
void Com_Printf(char *msg, ...); void Com_Printf(const char *msg, ...);
/* /*
* ========================================================== * ==========================================================

View file

@ -182,7 +182,7 @@ GetGameAPI(game_import_t *import)
* in shared source files can link * in shared source files can link
*/ */
void void
Sys_Error(char *error, ...) Sys_Error(const char *error, ...)
{ {
va_list argptr; va_list argptr;
char text[1024]; char text[1024];
@ -195,7 +195,7 @@ Sys_Error(char *error, ...)
} }
void void
Com_Printf(char *msg, ...) Com_Printf(const char *msg, ...)
{ {
va_list argptr; va_list argptr;
char text[1024]; char text[1024];

View file

@ -105,10 +105,10 @@ struct edict_s
typedef struct typedef struct
{ {
/* special messages */ /* special messages */
void (*bprintf)(int printlevel, char *fmt, ...); void (*bprintf)(int printlevel, const char *fmt, ...);
void (*dprintf)(char *fmt, ...); void (*dprintf)(const char *fmt, ...);
void (*cprintf)(edict_t *ent, int printlevel, char *fmt, ...); void (*cprintf)(edict_t *ent, int printlevel, const char *fmt, ...);
void (*centerprintf)(edict_t *ent, char *fmt, ...); void (*centerprintf)(edict_t *ent, const char *fmt, ...);
void (*sound)(edict_t *ent, int channel, int soundindex, float volume, void (*sound)(edict_t *ent, int channel, int soundindex, float volume,
float attenuation, float timeofs); float attenuation, float timeofs);
void (*positioned_sound)(vec3_t origin, edict_t *ent, int channel, void (*positioned_sound)(vec3_t origin, edict_t *ent, int channel,
@ -120,7 +120,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);
YQ2_ATTR_NORETURN_FUNCPTR void (*error)(char *fmt, ...); YQ2_ATTR_NORETURN_FUNCPTR void (*error)(const char *fmt, ...);
/* the *index functions create configstrings /* the *index functions create configstrings
and some internal server state */ and some internal server state */
@ -167,9 +167,9 @@ typedef struct
void (*FreeTags)(int tag); void (*FreeTags)(int tag);
/* console variable interaction */ /* console variable interaction */
cvar_t *(*cvar)(char *var_name, char *value, int flags); cvar_t *(*cvar)(const char *var_name, char *value, int flags);
cvar_t *(*cvar_set)(char *var_name, char *value); cvar_t *(*cvar_set)(const char *var_name, char *value);
cvar_t *(*cvar_forceset)(char *var_name, char *value); cvar_t *(*cvar_forceset)(const char *var_name, char *value);
/* ClientCommand and ServerCommand parameter access */ /* ClientCommand and ServerCommand parameter access */
int (*argc)(void); int (*argc)(void);

View file

@ -881,8 +881,8 @@ extern void CheckNeedPass ( void ) ;
extern void EndDMLevel ( void ) ; extern void EndDMLevel ( void ) ;
extern edict_t * CreateTargetChangeLevel ( char * map ) ; extern edict_t * CreateTargetChangeLevel ( char * map ) ;
extern void ClientEndServerFrames ( void ) ; extern void ClientEndServerFrames ( void ) ;
extern void Com_Printf ( char * msg , ... ) ; extern void Com_Printf ( const char * msg , ... ) ;
extern void Sys_Error ( char * error , ... ) ; extern void Sys_Error ( const char * error , ... ) ;
extern game_export_t * GetGameAPI ( game_import_t * import ) ; extern game_export_t * GetGameAPI ( game_import_t * import ) ;
extern void ShutdownGame ( void ) ; extern void ShutdownGame ( void ) ;
extern void SetItemNames ( void ) ; extern void SetItemNames ( void ) ;

View file

@ -233,9 +233,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, float attenuation, int soundindex, float volume, float attenuation,
float timeofs); float timeofs);
void SV_ClientPrintf(client_t *cl, int level, char *fmt, ...); void SV_ClientPrintf(client_t *cl, int level, const char *fmt, ...);
void SV_BroadcastPrintf(int level, char *fmt, ...); void SV_BroadcastPrintf(int level, const char *fmt, ...);
void SV_BroadcastCommand(char *fmt, ...); void SV_BroadcastCommand(const char *fmt, ...);
void SV_Nextserver(void); void SV_Nextserver(void);
void SV_ExecuteClientMessage(client_t *cl); void SV_ExecuteClientMessage(client_t *cl);

View file

@ -72,7 +72,7 @@ PF_Unicast(edict_t *ent, qboolean reliable)
* Debug print to server console * Debug print to server console
*/ */
void void
PF_dprintf(char *fmt, ...) PF_dprintf(const char *fmt, ...)
{ {
char msg[1024]; char msg[1024];
va_list argptr; va_list argptr;
@ -88,7 +88,7 @@ PF_dprintf(char *fmt, ...)
* Print to a single client * Print to a single client
*/ */
void void
PF_cprintf(edict_t *ent, int level, char *fmt, ...) PF_cprintf(edict_t *ent, int level, const char *fmt, ...)
{ {
char msg[1024]; char msg[1024];
va_list argptr; va_list argptr;
@ -124,7 +124,7 @@ PF_cprintf(edict_t *ent, int level, char *fmt, ...)
* centerprint to a single client * centerprint to a single client
*/ */
void void
PF_centerprintf(edict_t *ent, char *fmt, ...) PF_centerprintf(edict_t *ent, const char *fmt, ...)
{ {
char msg[1024]; char msg[1024];
va_list argptr; va_list argptr;
@ -150,7 +150,7 @@ PF_centerprintf(edict_t *ent, char *fmt, ...)
* Abort the server with a game error * Abort the server with a game error
*/ */
YQ2_ATTR_NORETURN_FUNCPTR void YQ2_ATTR_NORETURN_FUNCPTR void
PF_error(char *fmt, ...) PF_error(const char *fmt, ...)
{ {
char msg[1024]; char msg[1024];
va_list argptr; va_list argptr;

View file

@ -47,7 +47,7 @@ SV_FlushRedirect(int sv_redirected, char *outputbuf)
* Sends text across to be displayed if the level passes * Sends text across to be displayed if the level passes
*/ */
void void
SV_ClientPrintf(client_t *cl, int level, char *fmt, ...) SV_ClientPrintf(client_t *cl, int level, const char *fmt, ...)
{ {
va_list argptr; va_list argptr;
char string[1024]; char string[1024];
@ -65,7 +65,7 @@ SV_ClientPrintf(client_t *cl, int level, char *fmt, ...)
* Sends text to all active clients * Sends text to all active clients
*/ */
void void
SV_BroadcastPrintf(int level, char *fmt, ...) SV_BroadcastPrintf(int level, const char *fmt, ...)
{ {
va_list argptr; va_list argptr;
char string[2048]; char string[2048];
@ -109,7 +109,7 @@ SV_BroadcastPrintf(int level, char *fmt, ...)
* Sends text to all active clients * Sends text to all active clients
*/ */
void void
SV_BroadcastCommand(char *fmt, ...) SV_BroadcastCommand(const char *fmt, ...)
{ {
va_list argptr; va_list argptr;
char string[1024]; char string[1024];