forked from github/server
More PVS-Studio warnings eliminated.
This commit is contained in:
parent
91adf420bc
commit
ecd74c53f5
9 changed files with 21 additions and 25 deletions
|
@ -756,10 +756,8 @@ static int tolua_unit_get_spells(lua_State * L)
|
||||||
quicklist *slist = 0;
|
quicklist *slist = 0;
|
||||||
if (sb) {
|
if (sb) {
|
||||||
quicklist **slist_ptr = &sb->spells;
|
quicklist **slist_ptr = &sb->spells;
|
||||||
if (slist_ptr) {
|
|
||||||
slist = *slist_ptr;
|
slist = *slist_ptr;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return tolua_quicklist_push(L, "spellbook", "spell_entry", slist);
|
return tolua_quicklist_push(L, "spellbook", "spell_entry", slist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -184,7 +184,7 @@ map_region *mr_get(const view * vi, int xofs, int yofs)
|
||||||
static point *coor2point(const coordinate * c, point * p)
|
static point *coor2point(const coordinate * c, point * p)
|
||||||
{
|
{
|
||||||
assert(c && 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;
|
p->y = c->y * THEIGHT;
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
@ -262,7 +262,7 @@ static chtype mr_tile(const map_region * mr, int highlight)
|
||||||
const region *r = mr->r;
|
const region *r = mr->r;
|
||||||
switch (r->terrain->_name[0]) {
|
switch (r->terrain->_name[0]) {
|
||||||
case 'o':
|
case 'o':
|
||||||
return '.' | COLOR_PAIR(hl + COLOR_CYAN) | A_BOLD;
|
return '.' | COLOR_PAIR(hl + COLOR_CYAN) | A_BOLD; //-V525
|
||||||
case 'd':
|
case 'd':
|
||||||
return 'D' | COLOR_PAIR(hl + COLOR_YELLOW) | A_BOLD;
|
return 'D' | COLOR_PAIR(hl + COLOR_YELLOW) | A_BOLD;
|
||||||
case 't':
|
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;
|
region *first = (mr && mr->r && mr->r->next) ? mr->r->next : regions;
|
||||||
|
|
||||||
if (findmode == 'f') {
|
if (findmode == 'f') {
|
||||||
sprintf(sbuffer, "find-faction: %s", locate);
|
snprintf(sbuffer, sizeof(sbuffer), "find-faction: %s", locate);
|
||||||
statusline(st->wnd_status->handle, sbuffer);
|
statusline(st->wnd_status->handle, sbuffer);
|
||||||
f = findfaction(atoi36(locate));
|
f = findfaction(atoi36(locate));
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
|
|
|
@ -249,7 +249,7 @@ int destroy_cmd(unit * u, struct order *ord)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (con) {
|
if (con) {
|
||||||
/* TODO: Nicht an ZERSTÖRE mit Punktangabe angepasst! */
|
/* TODO: Nicht an ZERST<EFBFBD>RE mit Punktangabe angepasst! */
|
||||||
int c;
|
int c;
|
||||||
for (c = 0; con->materials[c].number; ++c) {
|
for (c = 0; con->materials[c].number; ++c) {
|
||||||
const requirement *rq = con->materials + 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.
|
/* Hier ist entweder maxsize == -1, oder completed < maxsize.
|
||||||
* Andernfalls ist das Datenfile oder sonstwas kaputt...
|
* Andernfalls ist das Datenfile oder sonstwas kaputt...
|
||||||
* (enno): Nein, das ist für Dinge, bei denen die nächste Ausbaustufe
|
* (enno): Nein, das ist f<EFBFBD>r Dinge, bei denen die n<EFBFBD>chste Ausbaustufe
|
||||||
* die gleiche wie die vorherige ist. z.b. gegenstände.
|
* die gleiche wie die vorherige ist. z.b. gegenst<EFBFBD>nde.
|
||||||
*/
|
*/
|
||||||
if (type->maxsize > 0) {
|
if (type->maxsize > 0) {
|
||||||
completed = completed % type->maxsize;
|
completed = completed % type->maxsize;
|
||||||
|
@ -759,10 +759,8 @@ build_building(unit * u, const building_type * btype, int id, int want, order *
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (b)
|
|
||||||
built = b->size;
|
built = b->size;
|
||||||
|
}
|
||||||
if (n <= 0 || n == INT_MAX) {
|
if (n <= 0 || n == INT_MAX) {
|
||||||
if (b == NULL) {
|
if (b == NULL) {
|
||||||
if (btype->maxsize > 0) {
|
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);
|
btname = LOC(lang, btype->_name);
|
||||||
|
|
||||||
if (want - built <= 0) {
|
if (want - built <= 0) {
|
||||||
/* gebäude fertig */
|
/* geb<EFBFBD>ude fertig */
|
||||||
new_order = default_order(lang);
|
new_order = default_order(lang);
|
||||||
}
|
}
|
||||||
else if (want != INT_MAX && btname) {
|
else if (want != INT_MAX && btname) {
|
||||||
/* reduzierte restgröße */
|
/* reduzierte restgr<EFBFBD><EFBFBD>e */
|
||||||
const char *hasspace = strchr(btname, ' ');
|
const char *hasspace = strchr(btname, ' ');
|
||||||
if (hasspace) {
|
if (hasspace) {
|
||||||
new_order =
|
new_order =
|
||||||
|
@ -833,7 +831,7 @@ build_building(unit * u, const building_type * btype, int id, int want, order *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (btname) {
|
else if (btname) {
|
||||||
/* Neues Haus, Befehl mit Gebäudename */
|
/* Neues Haus, Befehl mit Geb<EFBFBD>udename */
|
||||||
const char *hasspace = strchr(btname, ' ');
|
const char *hasspace = strchr(btname, ' ');
|
||||||
if (hasspace) {
|
if (hasspace) {
|
||||||
new_order = create_order(K_MAKE, lang, "\"%s\" %i", btname, b->no);
|
new_order = create_order(K_MAKE, lang, "\"%s\" %i", btname, b->no);
|
||||||
|
|
|
@ -82,7 +82,7 @@ static void test_group_readwrite(CuTest * tc)
|
||||||
mstream_init(&data.strm);
|
mstream_init(&data.strm);
|
||||||
gamedata_init(&data, &store, RELEASE_VERSION);
|
gamedata_init(&data, &store, RELEASE_VERSION);
|
||||||
f = test_create_faction(0);
|
f = test_create_faction(0);
|
||||||
g = new_group(f, "NW", 42);
|
new_group(f, "NW", 42);
|
||||||
g = new_group(f, "Egoisten", 43);
|
g = new_group(f, "Egoisten", 43);
|
||||||
key_set(&g->attribs, 44);
|
key_set(&g->attribs, 44);
|
||||||
al = ally_add(&g->allies, f);
|
al = ally_add(&g->allies, f);
|
||||||
|
|
|
@ -239,7 +239,6 @@ item_type *it_get_or_create(resource_type *rtype) {
|
||||||
item_type * itype;
|
item_type * itype;
|
||||||
assert(rtype);
|
assert(rtype);
|
||||||
itype = it_find(rtype->_name);
|
itype = it_find(rtype->_name);
|
||||||
assert(!itype || !itype->rtype || itype->rtype == rtype);
|
|
||||||
if (!itype) {
|
if (!itype) {
|
||||||
itype = (item_type *)calloc(sizeof(item_type), 1);
|
itype = (item_type *)calloc(sizeof(item_type), 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ static void test_strlcpy(CuTest * tc)
|
||||||
CuAssertIntEquals(tc, 4, (int)strlcpy(buffer, "herp", 4));
|
CuAssertIntEquals(tc, 4, (int)strlcpy(buffer, "herp", 4));
|
||||||
CuAssertStrEquals(tc, "her", buffer);
|
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);
|
CuAssertStrEquals(tc, "herp", buffer);
|
||||||
CuAssertIntEquals(tc, 0x7f, buffer[5]);
|
CuAssertIntEquals(tc, 0x7f, buffer[5]);
|
||||||
|
|
||||||
|
|
|
@ -244,7 +244,7 @@ void tt_register(trigger_type * tt)
|
||||||
trigger_type *tt_find(const char *name)
|
trigger_type *tt_find(const char *name)
|
||||||
{
|
{
|
||||||
trigger_type *tt = triggertypes;
|
trigger_type *tt = triggertypes;
|
||||||
while (tt && strcmp(tt->name, name))
|
while (tt && strcmp(tt->name, name)!=0)
|
||||||
tt = tt->next;
|
tt = tt->next;
|
||||||
return tt;
|
return tt;
|
||||||
}
|
}
|
||||||
|
|
|
@ -220,7 +220,7 @@ void log_fatal(const char *format, ...)
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_error(const char *format, ...)
|
void log_error(const char *format, ...) //-V524
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
|
|
|
@ -103,13 +103,13 @@ void random_source_inject_constant(double value) {
|
||||||
r_source = &constant_provider;
|
r_source = &constant_provider;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i = 0;
|
|
||||||
static double *values;
|
static double *values;
|
||||||
static int value_size = 0;
|
static int value_size;
|
||||||
|
static int value_index;
|
||||||
|
|
||||||
static double array_source (void) {
|
static double array_source (void) {
|
||||||
assert(i<value_size);
|
assert(value_index<value_size);
|
||||||
return values[i++];
|
return values[value_index++];
|
||||||
}
|
}
|
||||||
|
|
||||||
struct random_source array_provider = {
|
struct random_source array_provider = {
|
||||||
|
@ -117,6 +117,7 @@ struct random_source array_provider = {
|
||||||
};
|
};
|
||||||
|
|
||||||
void random_source_inject_array(double inject[], int size) {
|
void random_source_inject_array(double inject[], int size) {
|
||||||
|
int i;
|
||||||
assert(size > 0);
|
assert(size > 0);
|
||||||
value_size = size;
|
value_size = size;
|
||||||
if (values)
|
if (values)
|
||||||
|
@ -125,7 +126,7 @@ void random_source_inject_array(double inject[], int size) {
|
||||||
for (i=0; i < size; ++i) {
|
for (i=0; i < size; ++i) {
|
||||||
values[i] = inject[i];
|
values[i] = inject[i];
|
||||||
}
|
}
|
||||||
i = 0;
|
value_index = 0;
|
||||||
r_source = &array_provider;
|
r_source = &array_provider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue