From c3bf54e4945fda93dd1ef0dbb40724ceea04b190 Mon Sep 17 00:00:00 2001 From: Kevin Shanahan Date: Tue, 23 Apr 2013 14:39:44 +0930 Subject: [PATCH] common: add printf attribute to Error() declaration in cmdlib.h Fix a number of warnings now generated as a result. Signed-off-by: Kevin Shanahan --- include/common/cmdlib.h | 3 ++- light/entities.c | 12 ++++++------ light/ltface.c | 2 +- vis/state.c | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/include/common/cmdlib.h b/include/common/cmdlib.h index 0a05db4f..3869f24e 100644 --- a/include/common/cmdlib.h +++ b/include/common/cmdlib.h @@ -72,7 +72,8 @@ char *ExpandPathAndArchive(char *path); double I_FloatTime(void); -void Error(const char *error, ...) __attribute__((noreturn)); +void Error(const char *error, ...) + __attribute__((format(printf,1,2),noreturn)); int CheckParm(const char *check); FILE *SafeOpenWrite(const char *filename); diff --git a/light/entities.c b/light/entities.c index 49dbe433..caba66d9 100644 --- a/light/entities.c +++ b/light/entities.c @@ -289,15 +289,15 @@ LoadEntities(void) char key[MAX_ENT_KEY]; epair_t *epair; vec3_t vec; - int num_lights; + int memsize, num_lights; /* Count the entities and allocate memory */ max_entities = CountEntities(dentdata); - entities = malloc(max_entities * sizeof(*entities)); + memsize = max_entities * sizeof(*entities); + entities = malloc(memsize); if (!entities) - Error("%s: allocation of %d bytes failed\n", __func__, - max_entities * sizeof(*entities)); - memset(entities, 0, max_entities * sizeof(*entities)); + Error("%s: allocation of %d bytes failed\n", __func__, memsize); + memset(entities, 0, memsize); /* start parsing */ num_entities = 0; @@ -525,7 +525,7 @@ WriteEntitiesToString(void) entdatasize = Get_EntityStringSize(entities, num_entities); dentdata = malloc(entdatasize); if (!dentdata) - Error("%s: allocation of %d bytes failed\n", entdatasize); + Error("%s: allocation of %d bytes failed\n", __func__, entdatasize); space = entdatasize; pos = dentdata; diff --git a/light/ltface.c b/light/ltface.c index 42e47952..ac83fb71 100644 --- a/light/ltface.c +++ b/light/ltface.c @@ -339,7 +339,7 @@ CalcFaceExtents(const dface_t *face, const vec3_t offset, lightsurf_t *surf) " surface %d, %s extents = %d\n" " texture %s at (%s)\n" " surface normal (%s)\n", - face - dfaces, i ? "t" : "s", surf->texsize[i], + (int)(face - dfaces), i ? "t" : "s", surf->texsize[i], miptex->name, VecStr(worldpoint), VecStrf(plane->normal)); } } diff --git a/vis/state.c b/vis/state.c index 751c0bba..330e3dce 100644 --- a/vis/state.c +++ b/vis/state.c @@ -229,7 +229,7 @@ LoadVisState(void) /* Sanity check the headers */ if (state.version != VIS_STATE_VERSION) { fclose(infile); - Error("%s: state file version does not match"); + Error("%s: state file version does not match", __func__); } if (state.numportals != numportals || state.numleafs != portalleafs) { fclose(infile);