cppcheck warnings

This commit is contained in:
Enno Rehling 2018-02-25 20:06:47 +01:00
parent b7dcee7e08
commit 079a55fe41
3 changed files with 13 additions and 16 deletions

View File

@ -476,14 +476,14 @@ static int count_materials(unit *u, const construction *type, int n, int complet
assert(canuse >= 0); assert(canuse >= 0);
if (type->reqsize > 1) { if (type->reqsize > 1) {
int need, prebuilt; int prebuilt = required(completed, type->reqsize,
prebuilt = type->materials[c].number);
required(completed, type->reqsize, type->materials[c].number); while (n > 0) {
for (; n;) { int need =
need =
required(completed + n, type->reqsize, type->materials[c].number); required(completed + n, type->reqsize, type->materials[c].number);
if (need - prebuilt <= canuse) if (need - prebuilt <= canuse) {
break; break;
}
--n; /* TODO: optimieren? */ --n; /* TODO: optimieren? */
} }
} }

View File

@ -247,7 +247,7 @@ static void test_buildingowner_resets_when_empty(CuTest * tc)
u_set_building(u, bld); u_set_building(u, bld);
CuAssertPtrEquals(tc, u, building_owner(bld)); CuAssertPtrEquals(tc, u, building_owner(bld));
u->number = 0; u->number = 0;
CuAssertPtrEquals(tc, 0, building_owner(bld)); CuAssertPtrEquals(tc, NULL, building_owner(bld));
u->number = 1; u->number = 1;
CuAssertPtrEquals(tc, u, building_owner(bld)); CuAssertPtrEquals(tc, u, building_owner(bld));
test_teardown(); test_teardown();

View File

@ -121,10 +121,8 @@ static unit *unitorders(input *in, faction *f)
static faction *factionorders(void) static faction *factionorders(void)
{ {
faction *f = NULL;
int fid = getid(); int fid = getid();
faction *f = findfaction(fid);
f = findfaction(fid);
if (f != NULL && !fval(f, FFL_NPC)) { if (f != NULL && !fval(f, FFL_NPC)) {
char token[128]; char token[128];
@ -231,9 +229,8 @@ int readorders(const char *filename)
{ {
input in; input in;
int result; int result;
FILE *F = fopen(filename, "r");
FILE *F = NULL;
F = fopen(filename, "r");
if (!F) { if (!F) {
perror(filename); perror(filename);
return -1; return -1;