fix some cppcheck warnings

This commit is contained in:
Enno Rehling 2018-05-18 02:55:33 +02:00
parent 9e64f66409
commit 810bf3b40a
6 changed files with 7 additions and 39 deletions

View file

@ -3999,7 +3999,7 @@ void force_leave(region *r, battle *b) {
void do_battle(region * r) void do_battle(region * r)
{ {
battle *b = NULL; battle *b = NULL;
bool fighting = false; bool fighting;
ship *sh; ship *sh;
fighting = start_battle(r, &b); fighting = start_battle(r, &b);

View file

@ -530,33 +530,6 @@ attrib_type at_target = {
NO_READ NO_READ
}; };
unit *utarget(const unit * u)
{
attrib *a;
if (!fval(u, UFL_TARGET))
return NULL;
a = a_find(u->attribs, &at_target);
assert(a || !"flag set, but no target found");
return (unit *)a->data.v;
}
void usettarget(unit * u, const unit * t)
{
attrib *a = a_find(u->attribs, &at_target);
if (!a && t)
a = a_add(&u->attribs, a_new(&at_target));
if (a) {
if (!t) {
a_remove(&u->attribs, a);
freset(u, UFL_TARGET);
}
else {
a->data.v = (void *)t;
fset(u, UFL_TARGET);
}
}
}
/*********************/ /*********************/
/* at_siege */ /* at_siege */
/*********************/ /*********************/

View file

@ -141,12 +141,6 @@ extern "C" {
struct building *usiege(const struct unit *u); struct building *usiege(const struct unit *u);
void usetsiege(struct unit *u, const struct building *b); void usetsiege(struct unit *u, const struct building *b);
struct unit *utarget(const struct unit *u);
void usettarget(struct unit *u, const struct unit *b);
struct unit *utarget(const struct unit *u);
void usettarget(struct unit *u, const struct unit *b);
const char *uprivate(const struct unit *u); const char *uprivate(const struct unit *u);
void usetprivate(struct unit *u, const char *c); void usetprivate(struct unit *u, const char *c);

View file

@ -320,11 +320,12 @@ int walkingcapacity(const struct unit *u)
/* Genug Trolle, um die Restwagen zu ziehen? */ /* Genug Trolle, um die Restwagen zu ziehen? */
wagen_mit_trollen = u->number / 4; wagen_mit_trollen = u->number / 4;
if (wagen_mit_trollen > wagen_ohne_pferde) wagen_mit_trollen = wagen_ohne_pferde; if (wagen_mit_trollen > wagen_ohne_pferde) {
wagen_mit_trollen = wagen_ohne_pferde;
}
/* Wagenkapazität hinzuzählen */ /* Wagenkapazität hinzuzählen */
n += wagen_mit_trollen * vcap; n += wagen_mit_trollen * vcap;
wagen_ohne_pferde -= wagen_mit_trollen;
} }
n += animals * acap; n += animals * acap;

View file

@ -144,9 +144,9 @@ void str_replace(char *buffer, size_t size, const char *tmpl, const char *var, c
*s = 0; *s = 0;
} }
unsigned int str_hash(const char *s) int str_hash(const char *s)
{ {
unsigned int key = 0; int key = 0;
assert(s); assert(s);
while (*s) { while (*s) {
key = key * 37 + *s++; key = key * 37 + *s++;

View file

@ -26,7 +26,7 @@ extern "C" {
#endif #endif
void str_replace(char *buffer, size_t size, const char *tmpl, const char *var, const char *value); void str_replace(char *buffer, size_t size, const char *tmpl, const char *var, const char *value);
unsigned int str_hash(const char *s); int str_hash(const char *s);
size_t str_slprintf(char * dst, size_t size, const char * format, ...); size_t str_slprintf(char * dst, size_t size, const char * format, ...);
size_t str_strlcpy(char *dst, const char *src, size_t len); size_t str_strlcpy(char *dst, const char *src, size_t len);
size_t str_strlcat(char *dst, const char *src, size_t len); size_t str_strlcat(char *dst, const char *src, size_t len);