[build] Fix a pile of gcc 10 issues

gcc got stricter about array accesses, complicating progs macros, and
much better at detecting buffer overflows.
This commit is contained in:
Bill Currie 2020-12-21 02:12:51 +09:00
parent 09384eb703
commit 4f8a06ddd3
29 changed files with 100 additions and 93 deletions

View file

@ -142,7 +142,12 @@ extern const vec_t *const vec3_origin;
} while (0)
#define VectorIsZero(a) (!(a)[0] && !(a)[1] && !(a)[2])
#define VectorZero(a) ((a)[2] = (a)[1] = (a)[0] = 0);
#define VectorZero(a) \
do { \
(a)[0] = 0; \
(a)[1] = 0; \
(a)[2] = 0; \
} while (0)
#define VectorSet(a,b,c,d) \
do { \
(d)[0] = a; \

View file

@ -474,8 +474,8 @@ typedef union pr_type_u {
string_t string_var;
func_t func_var;
pr_int_t entity_var;
float vector_var[0]; // really 3, but this structure must be 32 bits
float quat_var[0]; // really 4, but this structure must be 32 bits
float vector_var; // really [3], but this structure must be 32 bits
float quat_var; // really [4], but this structure must be 32 bits
pr_int_t integer_var;
pointer_t pointer_var;
pr_uint_t uinteger_var;

View file

@ -445,7 +445,7 @@ void PR_Undefined (progs_t *pr, const char *type, const char *name) __attribute_
\hideinitializer
*/
#define G_VECTOR(p,o) G_var (p, o, vector)
#define G_VECTOR(p,o) (&G_var (p, o, vector))
/** Access a quaternion global. Can be assigned to.
@ -457,7 +457,7 @@ void PR_Undefined (progs_t *pr, const char *type, const char *name) __attribute_
\hideinitializer
*/
#define G_QUAT(p,o) G_var (p, o, quat)
#define G_QUAT(p,o) (&G_var (p, o, quat))
/** Access a string index global. Can be assigned to.
@ -661,7 +661,7 @@ void PR_Undefined (progs_t *pr, const char *type, const char *name) __attribute_
\hideinitializer
*/
#define P_VECTOR(p,n) P_var (p, n, vector)
#define P_VECTOR(p,n) (&P_var (p, n, vector))
/** Access a quaterion parameter. Can be used any way a quat_t variable can.
@ -673,7 +673,7 @@ void PR_Undefined (progs_t *pr, const char *type, const char *name) __attribute_
\hideinitializer
*/
#define P_QUAT(p,n) P_var (p, n, quat)
#define P_QUAT(p,n) (&P_var (p, n, quat))
/** Access a string index parameter. Can be assigned to.
@ -873,7 +873,7 @@ void PR_Undefined (progs_t *pr, const char *type, const char *name) __attribute_
\hideinitializer
*/
#define R_VECTOR(p) R_var (p, vector)
#define R_VECTOR(p) (&R_var (p, vector))
/** Access the VM function return value as a \c ::quat_t quaternion.
@ -884,7 +884,7 @@ void PR_Undefined (progs_t *pr, const char *type, const char *name) __attribute_
\hideinitializer
*/
#define R_QUAT(p) R_var (p, quat)
#define R_QUAT(p) (&R_var (p, quat))
/** Access the VM function return value as a ::string_t (a VM string reference).
@ -1054,7 +1054,7 @@ void PR_Undefined (progs_t *pr, const char *type, const char *name) __attribute_
\hideinitializer
*/
#define E_VECTOR(e,o) E_var (e, o, vector)
#define E_VECTOR(e,o) (&E_var (e, o, vector))
/** Access a quaternion entity field. Can be used any way a quat_t variable
can.

View file

@ -83,7 +83,7 @@ il_data_get (il_resources_t *res, unsigned index)
PR_RESGET (res->line_map, index);
}
static inline int
static inline int __attribute__((pure))
il_data_index (il_resources_t *res, il_data_t *line)
{
PR_RESINDEX (res->line_map, line);

View file

@ -1133,9 +1133,7 @@ pr_debug_vector_view (qfot_type_t *type, pr_type_t *value, void *_data)
__auto_type data = (pr_debug_data_t *) _data;
dstring_t *dstr = data->dstr;
dasprintf (dstr, "'%.9g %.9g %.9g'",
value->vector_var[0], value->vector_var[1],
value->vector_var[2]);
dasprintf (dstr, "'%.9g %.9g %.9g'", VectorExpand (&value->vector_var));
}
static void
@ -1213,9 +1211,7 @@ pr_debug_quat_view (qfot_type_t *type, pr_type_t *value, void *_data)
__auto_type data = (pr_debug_data_t *) _data;
dstring_t *dstr = data->dstr;
dasprintf (dstr, "'%.9g %.9g %.9g %.9g'",
value->vector_var[0], value->vector_var[1],
value->vector_var[2], value->vector_var[3]);
dasprintf (dstr, "'%.9g %.9g %.9g %.9g'", QuatExpand (&value->quat_var));
}
static void

View file

@ -512,10 +512,10 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
OPC.float_var = OPA.float_var + OPB.float_var;
break;
case OP_ADD_V:
VectorAdd (OPA.vector_var, OPB.vector_var, OPC.vector_var);
VectorAdd (&OPA.vector_var, &OPB.vector_var, &OPC.vector_var);
break;
case OP_ADD_Q:
QuatAdd (OPA.quat_var, OPB.quat_var, OPC.quat_var);
QuatAdd (&OPA.quat_var, &OPB.quat_var, &OPC.quat_var);
break;
case OP_ADD_S:
OPC.string_var = PR_CatStrings (pr,
@ -531,10 +531,11 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
OPC.float_var = OPA.float_var - OPB.float_var;
break;
case OP_SUB_V:
VectorSubtract (OPA.vector_var, OPB.vector_var, OPC.vector_var);
VectorSubtract (&OPA.vector_var, &OPB.vector_var,
&OPC.vector_var);
break;
case OP_SUB_Q:
QuatSubtract (OPA.quat_var, OPB.quat_var, OPC.quat_var);
QuatSubtract (&OPA.quat_var, &OPB.quat_var, &OPC.quat_var);
break;
case OP_MUL_D:
OPC_double_var = OPA_double_var * OPB_double_var;
@ -543,14 +544,14 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
OPC.float_var = OPA.float_var * OPB.float_var;
break;
case OP_MUL_V:
OPC.float_var = DotProduct (OPA.vector_var, OPB.vector_var);
OPC.float_var = DotProduct (&OPA.vector_var, &OPB.vector_var);
break;
case OP_MUL_DV:
{
// avoid issues with the likes of x = x.x * x;
// makes for faster code, too
double scale = OPA_double_var;
VectorScale (OPB.vector_var, scale, OPC.vector_var);
VectorScale (&OPB.vector_var, scale, &OPC.vector_var);
}
break;
case OP_MUL_VD:
@ -558,7 +559,7 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
// avoid issues with the likes of x = x * x.x;
// makes for faster code, too
double scale = OPB_double_var;
VectorScale (OPA.vector_var, scale, OPC.vector_var);
VectorScale (&OPA.vector_var, scale, &OPC.vector_var);
}
break;
case OP_MUL_FV:
@ -566,7 +567,7 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
// avoid issues with the likes of x = x.x * x;
// makes for faster code, too
float scale = OPA.float_var;
VectorScale (OPB.vector_var, scale, OPC.vector_var);
VectorScale (&OPB.vector_var, scale, &OPC.vector_var);
}
break;
case OP_MUL_VF:
@ -574,21 +575,21 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
// avoid issues with the likes of x = x * x.x;
// makes for faster code, too
float scale = OPB.float_var;
VectorScale (OPA.vector_var, scale, OPC.vector_var);
VectorScale (&OPA.vector_var, scale, &OPC.vector_var);
}
break;
case OP_MUL_Q:
QuatMult (OPA.quat_var, OPB.quat_var, OPC.quat_var);
QuatMult (&OPA.quat_var, &OPB.quat_var, &OPC.quat_var);
break;
case OP_MUL_QV:
QuatMultVec (OPA.quat_var, OPB.vector_var, OPC.vector_var);
QuatMultVec (&OPA.quat_var, &OPB.vector_var, &OPC.vector_var);
break;
case OP_MUL_DQ:
{
// avoid issues with the likes of x = x.s * x;
// makes for faster code, too
double scale = OPA_double_var;
QuatScale (OPB.quat_var, scale, OPC.quat_var);
QuatScale (&OPB.quat_var, scale, &OPC.quat_var);
}
break;
case OP_MUL_QD:
@ -596,7 +597,7 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
// avoid issues with the likes of x = x * x.s;
// makes for faster code, too
double scale = OPB_double_var;
QuatScale (OPA.quat_var, scale, OPC.quat_var);
QuatScale (&OPA.quat_var, scale, &OPC.quat_var);
}
break;
case OP_MUL_FQ:
@ -604,7 +605,7 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
// avoid issues with the likes of x = x.s * x;
// makes for faster code, too
float scale = OPA.float_var;
QuatScale (OPB.quat_var, scale, OPC.quat_var);
QuatScale (&OPB.quat_var, scale, &OPC.quat_var);
}
break;
case OP_MUL_QF:
@ -612,11 +613,11 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
// avoid issues with the likes of x = x * x.s;
// makes for faster code, too
float scale = OPB.float_var;
QuatScale (OPA.quat_var, scale, OPC.quat_var);
QuatScale (&OPA.quat_var, scale, &OPC.quat_var);
}
break;
case OP_CONJ_Q:
QuatConj (OPA.quat_var, OPC.quat_var);
QuatConj (&OPA.quat_var, &OPC.quat_var);
break;
case OP_DIV_D:
OPC_double_var = OPA_double_var / OPB_double_var;
@ -673,10 +674,10 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
OPC.integer_var = !FNZ (OPA);
break;
case OP_NOT_V:
OPC.integer_var = VectorIsZero (OPA.vector_var);
OPC.integer_var = VectorIsZero (&OPA.vector_var);
break;
case OP_NOT_Q:
OPC.integer_var = QuatIsZero (OPA.quat_var);
OPC.integer_var = QuatIsZero (&OPA.quat_var);
break;
case OP_NOT_S:
OPC.integer_var = !OPA.string_var ||
@ -692,11 +693,11 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
OPC.integer_var = OPA.float_var == OPB.float_var;
break;
case OP_EQ_V:
OPC.integer_var = VectorCompare (OPA.vector_var,
OPB.vector_var);
OPC.integer_var = VectorCompare (&OPA.vector_var,
&OPB.vector_var);
break;
case OP_EQ_Q:
OPC.integer_var = QuatCompare (OPA.quat_var, OPB.quat_var);
OPC.integer_var = QuatCompare (&OPA.quat_var, &OPB.quat_var);
break;
case OP_EQ_E:
OPC.integer_var = OPA.integer_var == OPB.integer_var;
@ -708,11 +709,11 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
OPC.integer_var = OPA.float_var != OPB.float_var;
break;
case OP_NE_V:
OPC.integer_var = !VectorCompare (OPA.vector_var,
OPB.vector_var);
OPC.integer_var = !VectorCompare (&OPA.vector_var,
&OPB.vector_var);
break;
case OP_NE_Q:
OPC.integer_var = !QuatCompare (OPA.quat_var, OPB.quat_var);
OPC.integer_var = !QuatCompare (&OPA.quat_var, &OPB.quat_var);
break;
case OP_LE_S:
case OP_GE_S:
@ -753,10 +754,10 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
OPB.integer_var = OPA.integer_var;
break;
case OP_STORE_V:
VectorCopy (OPA.vector_var, OPB.vector_var);
VectorCopy (&OPA.vector_var, &OPB.vector_var);
break;
case OP_STORE_Q:
QuatCopy (OPA.quat_var, OPB.quat_var);
QuatCopy (&OPA.quat_var, &OPB.quat_var);
break;
case OP_STORE_D:
OPB_double_var = OPA_double_var;
@ -782,7 +783,7 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
PR_BoundsCheck (pr, pointer, ev_vector);
}
ptr = pr->pr_globals + pointer;
VectorCopy (OPA.vector_var, ptr->vector_var);
VectorCopy (&OPA.vector_var, &ptr->vector_var);
break;
case OP_STOREP_Q:
pointer = OPB.integer_var;
@ -790,7 +791,7 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
PR_BoundsCheck (pr, pointer, ev_quat);
}
ptr = pr->pr_globals + pointer;
QuatCopy (OPA.quat_var, ptr->quat_var);
QuatCopy (&OPA.quat_var, &ptr->quat_var);
break;
case OP_STOREP_D:
pointer = OPB.integer_var;
@ -909,7 +910,7 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
PR_BoundsCheck (pr, pointer, ev_vector);
}
ptr = pr->pr_globals + pointer;
VectorCopy (ptr->vector_var, OPC.vector_var);
VectorCopy (&ptr->vector_var, &OPC.vector_var);
break;
case OP_LOADB_Q:
pointer = OPA.integer_var + OPB.integer_var;
@ -917,7 +918,7 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
PR_BoundsCheck (pr, pointer, ev_quat);
}
ptr = pr->pr_globals + pointer;
QuatCopy (ptr->quat_var, OPC.quat_var);
QuatCopy (&ptr->quat_var, &OPC.quat_var);
break;
case OP_LOADB_D:
pointer = OPA.integer_var + OPB.integer_var;
@ -948,7 +949,7 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
PR_BoundsCheck (pr, pointer, ev_vector);
}
ptr = pr->pr_globals + pointer;
VectorCopy (ptr->vector_var, OPC.vector_var);
VectorCopy (&ptr->vector_var, &OPC.vector_var);
break;
case OP_LOADBI_Q:
pointer = OPA.integer_var + (short) st->b;
@ -956,7 +957,7 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
PR_BoundsCheck (pr, pointer, ev_quat);
}
ptr = pr->pr_globals + pointer;
QuatCopy (ptr->quat_var, OPC.quat_var);
QuatCopy (&ptr->quat_var, &OPC.quat_var);
break;
case OP_LOADBI_D:
pointer = OPA.integer_var + (short) st->b;
@ -997,7 +998,7 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
PR_BoundsCheck (pr, pointer, ev_vector);
}
ptr = pr->pr_globals + pointer;
VectorCopy (OPA.vector_var, ptr->vector_var);
VectorCopy (&OPA.vector_var, &ptr->vector_var);
break;
case OP_STOREB_Q:
pointer = OPB.integer_var + OPC.integer_var;
@ -1005,7 +1006,7 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
PR_BoundsCheck (pr, pointer, ev_quat);
}
ptr = pr->pr_globals + pointer;
QuatCopy (OPA.quat_var, ptr->quat_var);
QuatCopy (&OPA.quat_var, &ptr->quat_var);
break;
case OP_STOREB_D:
pointer = OPB.integer_var + OPC.integer_var;
@ -1036,7 +1037,7 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
PR_BoundsCheck (pr, pointer, ev_vector);
}
ptr = pr->pr_globals + pointer;
VectorCopy (OPA.vector_var, ptr->vector_var);
VectorCopy (&OPA.vector_var, &ptr->vector_var);
break;
case OP_STOREBI_Q:
pointer = OPB.integer_var + (short) st->c;
@ -1044,7 +1045,7 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
PR_BoundsCheck (pr, pointer, ev_quat);
}
ptr = pr->pr_globals + pointer;
QuatCopy (OPA.quat_var, ptr->quat_var);
QuatCopy (&OPA.quat_var, &ptr->quat_var);
break;
case OP_STOREBI_D:
pointer = OPB.integer_var + (short) st->c;
@ -1131,7 +1132,7 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
PR_BoundsCheck (pr, pointer, ev_integer);
}
VectorCopy (ptr->vector_var, stk->vector_var);
VectorCopy (&ptr->vector_var, &stk->vector_var);
*pr->globals.stack = stack;
}
break;
@ -1148,7 +1149,7 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
PR_BoundsCheck (pr, pointer, ev_quat);
}
QuatCopy (ptr->quat_var, stk->quat_var);
QuatCopy (&ptr->quat_var, &stk->quat_var);
*pr->globals.stack = stack;
}
break;
@ -1189,7 +1190,7 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
PR_BoundsCheck (pr, pointer, ev_integer);
}
VectorCopy (ptr->vector_var, stk->vector_var);
VectorCopy (&ptr->vector_var, &stk->vector_var);
*pr->globals.stack = stack;
}
break;
@ -1206,7 +1207,7 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
PR_BoundsCheck (pr, pointer, ev_quat);
}
QuatCopy (ptr->quat_var, stk->quat_var);
QuatCopy (&ptr->quat_var, &stk->quat_var);
*pr->globals.stack = stack;
}
break;
@ -1287,7 +1288,7 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
PR_BoundsCheck (pr, pointer, ev_integer);
}
VectorCopy (ptr->vector_var, stk->vector_var);
VectorCopy (&ptr->vector_var, &stk->vector_var);
*pr->globals.stack = stack + 3;
}
break;
@ -1304,7 +1305,7 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
PR_BoundsCheck (pr, pointer, ev_quat);
}
QuatCopy (ptr->quat_var, stk->quat_var);
QuatCopy (&ptr->quat_var, &stk->quat_var);
*pr->globals.stack = stack + 4;
}
break;
@ -1345,7 +1346,7 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
PR_BoundsCheck (pr, pointer, ev_integer);
}
VectorCopy (ptr->vector_var, stk->vector_var);
VectorCopy (&ptr->vector_var, &stk->vector_var);
*pr->globals.stack = stack + 3;
}
break;
@ -1362,7 +1363,7 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
PR_BoundsCheck (pr, pointer, ev_quat);
}
QuatCopy (ptr->quat_var, stk->quat_var);
QuatCopy (&ptr->quat_var, &stk->quat_var);
*pr->globals.stack = stack + 4;
}
break;

View file

@ -92,10 +92,10 @@ PR_UglyValueString (progs_t *pr, etype_t type, pr_type_t *val, dstring_t *line)
dsprintf (line, "%d", val->integer_var);
break;
case ev_vector:
dsprintf (line, "%.9g %.9g %.9g", VectorExpand (val->vector_var));
dsprintf (line, "%.9g %.9g %.9g", VectorExpand (&val->vector_var));
break;
case ev_quat:
dsprintf (line, "%.9g %.9g %.9g %.9g", QuatExpand (val->quat_var));
dsprintf (line, "%.9g %.9g %.9g %.9g", QuatExpand (&val->quat_var));
break;
default:
dsprintf (line, "bad type %i", type);
@ -241,7 +241,7 @@ ED_ParseEpair (progs_t *pr, pr_type_t *base, pr_def_t *key, const char *s)
while (*v && *v != ' ')
v++;
*v = 0;
d->vector_var[i] = atof (w);
(&d->vector_var)[i] = atof (w);
w = v = v + 1;
}
free (string);

View file

@ -138,7 +138,7 @@ Mod_LoadAliasFrame (void *pin, int *posenum, maliasframedesc_t *frame,
pdaliasframe = (daliasframe_t *) pin;
strncpy (frame->name, pdaliasframe->name, sizeof (frame->name));
memcpy (frame->name, pdaliasframe->name, sizeof (frame->name));
frame->name[sizeof (frame->name) - 1] = 0;
frame->firstpose = (*posenum);
frame->numposes = 1;

View file

@ -85,7 +85,7 @@ table_get (hash_resources_t *res, int index)
PR_RESGET(res->table_map, index);
}
static inline int
static inline int __attribute__((pure))
table_index (hash_resources_t *res, bi_hashtab_t *table)
{
PR_RESINDEX(res->table_map, table);

View file

@ -80,7 +80,7 @@ msgbuf_get (msgbuf_resources_t *res, int index)
PR_RESGET(res->msgbuf_map, index);
}
static inline int
static inline int __attribute__((pure))
msgbuf_index (msgbuf_resources_t *res, msgbuf_t *msgbuf)
{
PR_RESINDEX(res->msgbuf_map, msgbuf);
@ -358,8 +358,7 @@ static void
bi_MsgBuf_ReadCoordAngleV (progs_t *pr)
{
msgbuf_t *mb = get_msgbuf (pr, __FUNCTION__, P_INT (pr, 0));
MSG_ReadCoordAngleV (&mb->msg, P_GPOINTER (pr, 1)->vector_var,
P_GPOINTER (pr, 2)->vector_var);
MSG_ReadCoordAngleV (&mb->msg, P_VECTOR (pr, 1), P_VECTOR (pr, 2));
}
static void

View file

@ -108,7 +108,7 @@ dtable_get (probj_t *probj, int index)
PR_RESGET (probj->dtables, index);
}
static inline int
static inline int __attribute__((pure))
dtable_index (probj_t *probj, dtable_t *dtable)
{
PR_RESINDEX (probj->dtables, dtable);

View file

@ -84,7 +84,7 @@ plist_get (plist_resources_t *res, unsigned index)
PR_RESGET(res->plist_map, index);
}
static inline int
static inline int __attribute__((pure))
plist_index (plist_resources_t *res, bi_plist_t *plist)
{
PR_RESINDEX(res->plist_map, plist);

View file

@ -77,7 +77,7 @@ handle_get (qfile_resources_t *res, int index)
PR_RESGET(res->handle_map, index);
}
static inline int
static inline int __attribute__((pure))
handle_index (qfile_resources_t *res, qfile_t *handle)
{
PR_RESINDEX(res->handle_map, handle);

View file

@ -78,7 +78,7 @@ script_get (script_resources_t *res, int index)
PR_RESGET(res->scripts, index);
}
static inline int
static inline int __attribute__((pure))
script_index (script_resources_t *res, rua_script_t *script)
{
PR_RESINDEX(res->scripts, script);

View file

@ -98,7 +98,7 @@ res_set_get (set_resources_t *res, int index)
PR_RESGET(res->set_map, index);
}
static inline int
static inline int __attribute__((pure))
res_set_index (set_resources_t *res, bi_set_t *set)
{
PR_RESINDEX(res->set_map, set);
@ -128,7 +128,7 @@ res_set_iter_get (set_resources_t *res, int index)
PR_RESGET(res->set_iter_map, index);
}
static inline int
static inline int __attribute__((pure))
res_set_iter_index (set_resources_t *res, bi_set_iter_t *set_iter)
{
PR_RESINDEX(res->set_iter_map, set_iter);

View file

@ -577,7 +577,8 @@ Hunk_AllocName (int size, const char *name)
h->size = size;
h->sentinal = HUNK_SENTINAL;
strncpy (h->name, name, 8);
memcpy (h->name, name, 8);
h->name[7] = 0;
return (void *) (h + 1);
}

View file

@ -101,7 +101,7 @@ qpic_get (draw_resources_t *res, int index)
PR_RESGET (res->qpic_map, index);
}
static inline int
static inline int __attribute__((pure))
qpic_index (draw_resources_t *res, qpic_res_t *qp)
{
PR_RESINDEX (res->qpic_map, qp);

View file

@ -208,7 +208,7 @@ extern progs_t sv_pr_state;
#define SVstring(e,f) SVFIELD (e, f, string)
#define SVfunc(e,f) SVFIELD (e, f, func)
#define SVentity(e,f) SVFIELD (e, f, entity)
#define SVvector(e,f) SVFIELD (e, f, vector)
#define SVvector(e,f) (&SVFIELD (e, f, vector))
#define SVinteger(e,f) SVFIELD (e, f, integer)
#if TYPECHECK_PROGS
#define SVdouble(e,f) E_DOUBLE (e, PR_AccessField (&sv_pr_state, #f, ev_##t, __FILE__, __LINE__))

View file

@ -193,7 +193,7 @@ extern progs_t sv_pr_state;
#define SVstring(e,f) SVFIELD (e, f, string)
#define SVfunc(e,f) SVFIELD (e, f, func)
#define SVentity(e,f) SVFIELD (e, f, entity)
#define SVvector(e,f) SVFIELD (e, f, vector)
#define SVvector(e,f) (&SVFIELD (e, f, vector))
#define SVinteger(e,f) SVFIELD (e, f, integer)
#if TYPECHECK_PROGS
#define SVdouble(e,f) E_DOUBLE (e, PR_AccessField (&sv_pr_state, #f, ev_##t, __FILE__, __LINE__))

View file

@ -738,7 +738,7 @@ SpectatorMove (void)
// friction
speed = DotProduct (pmove.velocity, pmove.velocity);
if (speed < 1) {
VectorZero (pmove.velocity)
VectorZero (pmove.velocity);
} else {
speed = sqrt (speed);
drop = 0;

View file

@ -101,8 +101,8 @@ free_edict (progs_t *pr, edict_t *ent)
ent->v[sv_fields.frame].float_var = 0;
ent->v[sv_fields.nextthink].float_var = -1;
ent->v[sv_fields.solid].float_var = 0;
memset (ent->v[sv_fields.origin].vector_var, 0, 3*sizeof (float));
memset (ent->v[sv_fields.angles].vector_var, 0, 3*sizeof (float));
memset (&ent->v[sv_fields.origin].vector_var, 0, 3*sizeof (float));
memset (&ent->v[sv_fields.angles].vector_var, 0, 3*sizeof (float));
} else {
ED_ClearEdict (pr, ent, 0);
}

View file

@ -148,7 +148,7 @@ window_get (qwaq_resources_t *res, unsigned index)
PR_RESGET(res->window_map, index);
}
static inline int
static inline int __attribute__((pure))
window_index (qwaq_resources_t *res, window_t *win)
{
PR_RESINDEX (res->window_map, win);
@ -194,7 +194,7 @@ panel_get (qwaq_resources_t *res, unsigned index)
PR_RESGET(res->panel_map, index);
}
static inline int
static inline int __attribute__((pure))
panel_index (qwaq_resources_t *res, panel_t *win)
{
PR_RESINDEX (res->panel_map, win);

View file

@ -93,7 +93,7 @@ target_get (qwaq_debug_t *debug, unsigned index)
PR_RESGET (debug->targets, index);
}
static inline int
static inline int __attribute__((pure))
target_index (qwaq_debug_t *debug, qwaq_target_t *target)
{
PR_RESINDEX (debug->targets, target);

View file

@ -52,7 +52,7 @@ editbuffer_get (qwaq_ebresources_t *res, unsigned index)
PR_RESGET (res->buffers, index);
}
static inline int
static inline int __attribute__((pure))
editbuffer_index (qwaq_ebresources_t *res, editbuffer_t *buffer)
{
PR_RESINDEX (res->buffers, buffer);

View file

@ -86,6 +86,7 @@ open_file (const char *path, int *len)
if (!file) {
strerror_r(errno, errbuff, sizeof (errbuff));
Sys_Printf ("%s\n", errbuff);
*len = 0;
return 0;
}
*len = Qfilesize (file);

View file

@ -180,6 +180,8 @@ MarkLeakTrail2 (void)
vec3_t wc, pwc;
const vec_t *v;
VectorZero (wc);
leakfile = fopen (options.pointfile, "w");
if (!leakfile)
Sys_Error ("Couldn't open %s\n", options.pointfile);

View file

@ -101,8 +101,8 @@ extern pr_info_t pr;
#define D_DOUBLE(d) (*(double *) ((d)->space->data + (d)->offset))
#define D_FLOAT(d) D_var (float, d)
#define D_INT(d) D_var (integer, d)
#define D_VECTOR(d) D_var (vector, d)
#define D_QUAT(d) D_var (quat, d)
#define D_VECTOR(d) (&D_var (vector, d))
#define D_QUAT(d) (&D_var (quat, d))
#define D_STRING(d) D_var (string, d)
#define D_GETSTR(d) GETSTR (D_STRING (d))
#define D_FUNCTION(d) D_var (func, d)

View file

@ -34,7 +34,7 @@
///@{
float noise3d (vec3_t v, int num) __attribute__((pure));
float noiseXYZ (float x, float y, float z, int num) __attribute__((pure));
float noiseXYZ (float x, float y, float z, int num) __attribute__((const));
float noise_scaled (vec3_t v, float s, int num) __attribute__((pure));
float noise_perlin (vec3_t v, float p, int num) __attribute__((pure));
void snap_vector (vec3_t v_old, vec3_t v_new, float scale);

View file

@ -178,15 +178,17 @@ SetQdirFromPath (char *path)
static const char *
ExpandPath (const char *path)
{
static char full[1024];
static dstring_t *full;
//FIXME buffer overflow central
if (!full) {
full = dstring_new();
}
//if (!qdir)
// Sys_Error ("ExpandPath called without qdir set");
if (path[0] == '/' || path[0] == '\\' || path[1] == ':')
return path;
sprintf (full, "%s%s", qdir, path);
return full;
dsprintf (full, "%s%s", qdir, path);
return full->str;
}
static void