diff --git a/s/travis-build b/s/travis-build index 2da3ed7b5..6b14e8848 100755 --- a/s/travis-build +++ b/s/travis-build @@ -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 - diff --git a/src/kernel/item.c b/src/kernel/item.c index 9d750cb2f..b2a35669a 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -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) diff --git a/src/kernel/pool.c b/src/kernel/pool.c index d85846f64..e58bc131e 100644 --- a/src/kernel/pool.c +++ b/src/kernel/pool.c @@ -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; diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 2e3dab804..cb42071b0 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -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