From 7406e0308e85179f0104a785ea233abc989b8314 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 24 Feb 2020 11:28:43 +0900 Subject: [PATCH] Fix some warnings picked up in an optimized build --- include/QF/progs.h | 6 +++--- libs/console/buffer.c | 2 +- libs/gamecode/pr_debug.c | 8 ++++---- tools/qfcc/source/obj_file.c | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/QF/progs.h b/include/QF/progs.h index 78b3036c7..d007ac81f 100644 --- a/include/QF/progs.h +++ b/include/QF/progs.h @@ -1787,7 +1787,7 @@ struct progs_s { \return C pointer represented by the parameter. 0 offset -> NULL */ static inline pr_type_t * -PR_GetPointer (progs_t *pr, pointer_t o) +PR_GetPointer (const progs_t *pr, pointer_t o) { return o ? pr->pr_globals + o : 0; } @@ -1798,9 +1798,9 @@ PR_GetPointer (progs_t *pr, pointer_t o) \return Progs offset/pointer represented by \c p. NULL -> 0 offset */ static inline pointer_t -PR_SetPointer (progs_t *pr, void *p) +PR_SetPointer (const progs_t *pr, const void *p) { - return p ? (pr_type_t *) p - pr->pr_globals : 0; + return p ? (const pr_type_t *) p - pr->pr_globals : 0; } ///@} diff --git a/libs/console/buffer.c b/libs/console/buffer.c index d494c0655..2aa477abc 100644 --- a/libs/console/buffer.c +++ b/libs/console/buffer.c @@ -92,7 +92,7 @@ Con_BufferAddText (con_buffer_t *buf, const char *text) } while (len--) { byte c = *pos++ = *text++; - if ((size_t) (pos - buf->buffer) >= buf->buffer_size) + if (pos >= buf->buffer + buf->buffer_size) pos = buf->buffer; cur_line->len++; if (pos == tail_line->text) { diff --git a/libs/gamecode/pr_debug.c b/libs/gamecode/pr_debug.c index 9b0deece5..d895f631a 100644 --- a/libs/gamecode/pr_debug.c +++ b/libs/gamecode/pr_debug.c @@ -196,8 +196,8 @@ pr_debug_expression_error (script_t *script, const char *msg) } #define RUP(x,a) (((x) + ((a) - 1)) & ~((a) - 1)) -static pr_short_t -pr_debug_type_size (progs_t *pr, qfot_type_t *type) +static pr_short_t __attribute__((pure)) +pr_debug_type_size (const progs_t *pr, const qfot_type_t *type) { pr_short_t size; qfot_type_t *aux_type; @@ -208,7 +208,7 @@ pr_debug_type_size (progs_t *pr, qfot_type_t *type) case ty_union: size = 0; for (pr_int_t i = 0; i < type->t.strct.num_fields; i++) { - qfot_var_t *field = &type->t.strct.fields[i]; + const qfot_var_t *field = &type->t.strct.fields[i]; aux_type = &G_STRUCT (pr, qfot_type_t, field->type); size = max (size, field->offset + pr_debug_type_size (pr, aux_type)); @@ -995,7 +995,7 @@ pr_debug_pointer_view (qfot_type_t *type, pr_type_t *value, void *_data) progs_t *pr = data->pr; dstring_t *dstr = data->dstr; pointer_t ofs = value->integer_var; - pr_def_t *def; + pr_def_t *def = 0; if (pr_debug->int_val && pr->debug) { def = PR_Get_Local_Def (pr, ofs); diff --git a/tools/qfcc/source/obj_file.c b/tools/qfcc/source/obj_file.c index 735a68ab0..855e48b61 100644 --- a/tools/qfcc/source/obj_file.c +++ b/tools/qfcc/source/obj_file.c @@ -891,7 +891,7 @@ qfo_to_progs (qfo_t *qfo, int *size) int xdefs_start; unsigned big_locals = 0; int big_func = 0; - pr_xdefs_t *xdefs; + pr_xdefs_t *xdefs = 0; xdef_t *xdef; *size = RUP (sizeof (dprograms_t), 16);