[util] Make va return const char *

And clean up the resulting mess.

I don't know why it wasn't doing so, but it certainly should have been.
This commit is contained in:
Bill Currie 2021-03-29 17:24:30 +09:00
parent 2e1f3cda89
commit a754dbca37
9 changed files with 12 additions and 11 deletions

View file

@ -73,7 +73,7 @@ void va_destroy_context (va_ctx_t *ctx);
* to va sent to a 4th) with a reduced risk of strings being
* trampled.
*/
char *va(va_ctx_t *ctx, const char *format, ...) __attribute__((format(PRINTF,2,3)));
const char *va(va_ctx_t *ctx, const char *format, ...) __attribute__((format(PRINTF,2,3)));
/** Does a varargs printf into a malloced buffer.
*

View file

@ -240,7 +240,7 @@ Condump_f (void)
int line = con->current - con->numlines;
const char *start, *end;
QFile *file;
char *name;
const char *name;
if (Cmd_Argc () != 2) {
Sys_Printf ("usage: condump <filename>\n");

View file

@ -162,7 +162,8 @@ GIB_Var_Get_Very_Complex (hashtab_t ** first, hashtab_t ** second, dstring_t *ke
unsigned int i, index = 0, index2 = 0, n, protect, varstartskip;
gib_var_t *var = 0;
cvar_t *cvar;
char c, *str;
char c;
const char *str;
qboolean done = false;
for (i = start, protect = 0; !done; i++) {

View file

@ -54,7 +54,7 @@
static gltex_t gl_notexture = { };
static tex_t *
Mod_LoadAnExternalTexture (char *tname, char *mname)
Mod_LoadAnExternalTexture (const char *tname, const char *mname)
{
char rname[32];
tex_t *image;

View file

@ -71,7 +71,7 @@ va_destroy_context (va_ctx_t *ctx)
free (ctx);
}
VISIBLE char *
VISIBLE const char *
va (va_ctx_t *ctx, const char *fmt, ...)
{
static va_ctx_t *_ctx;

View file

@ -108,7 +108,7 @@ CL_WriteConfiguration (void)
// dedicated servers initialize the host but don't parse and set the
// config.cfg cvars
if (host_initialized && !isDedicated && cl_writecfg->int_val) {
char *path = va (0, "%s/config.cfg", qfs_gamedir->dir.def);
const char *path = va (0, "%s/config.cfg", qfs_gamedir->dir.def);
f = QFS_WOpen (path, 0);
if (!f) {
Sys_Printf ("Couldn't write config.cfg.\n");

View file

@ -1520,7 +1520,7 @@ Host_WriteConfiguration (void)
QFile *f;
if (host_initialized && cl_writecfg->int_val) {
char *path = va (0, "%s/config.cfg", qfs_gamedir->dir.def);
const char *path = va (0, "%s/config.cfg", qfs_gamedir->dir.def);
f = QFS_WOpen (path, 0);
if (!f) {

View file

@ -357,7 +357,7 @@ Model_NextDownload (void)
map_cfg (cl.model_name[1], 0);
for (i = 1; i < cl.nummodels; i++) {
char *info_key = 0;
const char *info_key = 0;
if (!cl.model_name[i][0])
break;

View file

@ -309,9 +309,9 @@ SV_Modellist_f (void *unused)
static void
SV_PreSpawn_f (void *unused)
{
char *command;
int buf, size;
unsigned int check;
const char *command;
int buf, size;
unsigned check;
sizebuf_t *msg;
if (host_client->state != cs_connected) {