pass cppcheck v 1.54 default checks

This commit is contained in:
Enno Rehling 2017-12-08 19:26:26 +01:00
parent 4588419814
commit 5e435a7c0b
4 changed files with 20 additions and 16 deletions

View File

@ -19,13 +19,12 @@ cd tests
set -e
[ -z $BUILD ] && BUILD=Debug ; export BUILD
s/cmake-init
s/build
cd $ROOT
inifile
cppcheck --version
cppcheck --quiet --error-exitcode=1 src
s/build
cd process
make
cd $ROOT
inifile
s/runtests -V
integration_tests
cd ../process
make

View File

@ -746,11 +746,13 @@ void init_resources(void)
int get_money(const unit * u)
{
const struct resource_type *rtype = get_resourcetype(R_SILVER);
const item *i = u->items;
while (i && i->type->rtype != rtype) {
i = i->next;
const item *i;
for (i = u->items; i; i = i->next) {
if (i->type->rtype == rtype) {
return i->number;
}
}
return i ? i->number : 0;
return 0;
}
int set_money(unit * u, int v)

View File

@ -114,7 +114,7 @@ int change_reservation(unit * u, const item_type * itype, int value)
res->type = itype;
res->value = value;
}
else if (res && res->value + value <= 0) {
else if (res->value + value <= 0) {
*rp = res->next;
free(res);
return 0;
@ -139,7 +139,7 @@ int set_resvalue(unit * u, const item_type * itype, int value)
res->type = itype;
res->value = value;
}
else if (res && value <= 0) {
else if (value <= 0) {
*rp = res->next;
free(res);
return 0;

View File

@ -394,11 +394,14 @@ faction *dfindhash(int no)
}
#else
struct faction *dfindhash(int no) {
unit *u = deleted_units;
while (u && u->no != no) {
u = u->next;
unit *u;
for (u = deleted_units; u; u = u->next) {
if (u->no == no) {
return u->faction;
}
}
return u ? u->faction : NULL;
return NULL;
}
#endif