forked from github/server
cppcheck warnings
This commit is contained in:
parent
b7dcee7e08
commit
079a55fe41
3 changed files with 13 additions and 16 deletions
|
@ -476,14 +476,14 @@ static int count_materials(unit *u, const construction *type, int n, int complet
|
|||
|
||||
assert(canuse >= 0);
|
||||
if (type->reqsize > 1) {
|
||||
int need, prebuilt;
|
||||
prebuilt =
|
||||
required(completed, type->reqsize, type->materials[c].number);
|
||||
for (; n;) {
|
||||
need =
|
||||
int prebuilt = required(completed, type->reqsize,
|
||||
type->materials[c].number);
|
||||
while (n > 0) {
|
||||
int need =
|
||||
required(completed + n, type->reqsize, type->materials[c].number);
|
||||
if (need - prebuilt <= canuse)
|
||||
if (need - prebuilt <= canuse) {
|
||||
break;
|
||||
}
|
||||
--n; /* TODO: optimieren? */
|
||||
}
|
||||
}
|
||||
|
|
|
@ -247,7 +247,7 @@ static void test_buildingowner_resets_when_empty(CuTest * tc)
|
|||
u_set_building(u, bld);
|
||||
CuAssertPtrEquals(tc, u, building_owner(bld));
|
||||
u->number = 0;
|
||||
CuAssertPtrEquals(tc, 0, building_owner(bld));
|
||||
CuAssertPtrEquals(tc, NULL, building_owner(bld));
|
||||
u->number = 1;
|
||||
CuAssertPtrEquals(tc, u, building_owner(bld));
|
||||
test_teardown();
|
||||
|
|
|
@ -121,10 +121,8 @@ static unit *unitorders(input *in, faction *f)
|
|||
|
||||
static faction *factionorders(void)
|
||||
{
|
||||
faction *f = NULL;
|
||||
int fid = getid();
|
||||
|
||||
f = findfaction(fid);
|
||||
faction *f = findfaction(fid);
|
||||
|
||||
if (f != NULL && !fval(f, FFL_NPC)) {
|
||||
char token[128];
|
||||
|
@ -231,9 +229,8 @@ int readorders(const char *filename)
|
|||
{
|
||||
input in;
|
||||
int result;
|
||||
FILE *F = fopen(filename, "r");
|
||||
|
||||
FILE *F = NULL;
|
||||
F = fopen(filename, "r");
|
||||
if (!F) {
|
||||
perror(filename);
|
||||
return -1;
|
||||
|
|
Loading…
Reference in a new issue