More PVS-Studio warnings eliminated.

This commit is contained in:
Enno Rehling 2016-11-23 19:19:04 +01:00
parent 91adf420bc
commit ecd74c53f5
9 changed files with 21 additions and 25 deletions

View file

@ -756,9 +756,7 @@ static int tolua_unit_get_spells(lua_State * L)
quicklist *slist = 0;
if (sb) {
quicklist **slist_ptr = &sb->spells;
if (slist_ptr) {
slist = *slist_ptr;
}
slist = *slist_ptr;
}
return tolua_quicklist_push(L, "spellbook", "spell_entry", slist);
}

View file

@ -184,7 +184,7 @@ map_region *mr_get(const view * vi, int xofs, int yofs)
static point *coor2point(const coordinate * c, point * p)
{
assert(c && p);
p->x = c->x * TWIDTH + c->y * TWIDTH / 2;
p->x = c->x * TWIDTH + c->y * TWIDTH / 2; //-V537
p->y = c->y * THEIGHT;
return p;
}
@ -262,7 +262,7 @@ static chtype mr_tile(const map_region * mr, int highlight)
const region *r = mr->r;
switch (r->terrain->_name[0]) {
case 'o':
return '.' | COLOR_PAIR(hl + COLOR_CYAN) | A_BOLD;
return '.' | COLOR_PAIR(hl + COLOR_CYAN) | A_BOLD; //-V525
case 'd':
return 'D' | COLOR_PAIR(hl + COLOR_YELLOW) | A_BOLD;
case 't':
@ -1167,7 +1167,7 @@ static void handlekey(state * st, int c)
region *first = (mr && mr->r && mr->r->next) ? mr->r->next : regions;
if (findmode == 'f') {
sprintf(sbuffer, "find-faction: %s", locate);
snprintf(sbuffer, sizeof(sbuffer), "find-faction: %s", locate);
statusline(st->wnd_status->handle, sbuffer);
f = findfaction(atoi36(locate));
if (f == NULL) {

View file

@ -249,7 +249,7 @@ int destroy_cmd(unit * u, struct order *ord)
}
if (con) {
/* TODO: Nicht an ZERSTÖRE mit Punktangabe angepasst! */
/* TODO: Nicht an ZERST<EFBFBD>RE mit Punktangabe angepasst! */
int c;
for (c = 0; con->materials[c].number; ++c) {
const requirement *rq = con->materials + c;
@ -513,8 +513,8 @@ int build(unit * u, const construction * ctype, int completed, int want)
/* Hier ist entweder maxsize == -1, oder completed < maxsize.
* Andernfalls ist das Datenfile oder sonstwas kaputt...
* (enno): Nein, das ist für Dinge, bei denen die chste Ausbaustufe
* die gleiche wie die vorherige ist. z.b. gegenstände.
* (enno): Nein, das ist f<EFBFBD>r Dinge, bei denen die n<EFBFBD>chste Ausbaustufe
* die gleiche wie die vorherige ist. z.b. gegenst<EFBFBD>nde.
*/
if (type->maxsize > 0) {
completed = completed % type->maxsize;
@ -759,10 +759,8 @@ build_building(unit * u, const building_type * btype, int id, int want, order *
return 0;
}
}
}
if (b)
built = b->size;
}
if (n <= 0 || n == INT_MAX) {
if (b == NULL) {
if (btype->maxsize > 0) {
@ -817,11 +815,11 @@ build_building(unit * u, const building_type * btype, int id, int want, order *
btname = LOC(lang, btype->_name);
if (want - built <= 0) {
/* gebäude fertig */
/* geb<EFBFBD>ude fertig */
new_order = default_order(lang);
}
else if (want != INT_MAX && btname) {
/* reduzierte restgröße */
/* reduzierte restgr<EFBFBD><EFBFBD>e */
const char *hasspace = strchr(btname, ' ');
if (hasspace) {
new_order =
@ -833,7 +831,7 @@ build_building(unit * u, const building_type * btype, int id, int want, order *
}
}
else if (btname) {
/* Neues Haus, Befehl mit Gebäudename */
/* Neues Haus, Befehl mit Geb<EFBFBD>udename */
const char *hasspace = strchr(btname, ' ');
if (hasspace) {
new_order = create_order(K_MAKE, lang, "\"%s\" %i", btname, b->no);

View file

@ -82,7 +82,7 @@ static void test_group_readwrite(CuTest * tc)
mstream_init(&data.strm);
gamedata_init(&data, &store, RELEASE_VERSION);
f = test_create_faction(0);
g = new_group(f, "NW", 42);
new_group(f, "NW", 42);
g = new_group(f, "Egoisten", 43);
key_set(&g->attribs, 44);
al = ally_add(&g->allies, f);

View file

@ -239,7 +239,6 @@ item_type *it_get_or_create(resource_type *rtype) {
item_type * itype;
assert(rtype);
itype = it_find(rtype->_name);
assert(!itype || !itype->rtype || itype->rtype == rtype);
if (!itype) {
itype = (item_type *)calloc(sizeof(item_type), 1);
}

View file

@ -32,7 +32,7 @@ static void test_strlcpy(CuTest * tc)
CuAssertIntEquals(tc, 4, (int)strlcpy(buffer, "herp", 4));
CuAssertStrEquals(tc, "her", buffer);
CuAssertIntEquals(tc, 4, (int)strlcpy(buffer, "herp", 8));
CuAssertIntEquals(tc, 4, (int)strlcpy(buffer, "herp", 8)); //-V666
CuAssertStrEquals(tc, "herp", buffer);
CuAssertIntEquals(tc, 0x7f, buffer[5]);

View file

@ -244,7 +244,7 @@ void tt_register(trigger_type * tt)
trigger_type *tt_find(const char *name)
{
trigger_type *tt = triggertypes;
while (tt && strcmp(tt->name, name))
while (tt && strcmp(tt->name, name)!=0)
tt = tt->next;
return tt;
}

View file

@ -220,7 +220,7 @@ void log_fatal(const char *format, ...)
va_end(args);
}
void log_error(const char *format, ...)
void log_error(const char *format, ...) //-V524
{
va_list args;
va_start(args, format);

View file

@ -103,13 +103,13 @@ void random_source_inject_constant(double value) {
r_source = &constant_provider;
}
static int i = 0;
static double *values;
static int value_size = 0;
static int value_size;
static int value_index;
static double array_source (void) {
assert(i<value_size);
return values[i++];
assert(value_index<value_size);
return values[value_index++];
}
struct random_source array_provider = {
@ -117,6 +117,7 @@ struct random_source array_provider = {
};
void random_source_inject_array(double inject[], int size) {
int i;
assert(size > 0);
value_size = size;
if (values)
@ -125,7 +126,7 @@ void random_source_inject_array(double inject[], int size) {
for (i=0; i < size; ++i) {
values[i] = inject[i];
}
i = 0;
value_index = 0;
r_source = &array_provider;
}