quelling some static analysis complaints.

This commit is contained in:
Enno Rehling 2016-11-19 20:57:10 +01:00
parent eabaf8bebb
commit 19a0c2ddb3
7 changed files with 18 additions and 19 deletions

View file

@ -211,7 +211,7 @@ border_type *find_bordertype(const char *name)
{
border_type *bt = bordertypes;
while (bt && strcmp(bt->__name, name))
while (bt && strcmp(bt->__name, name)!=0)
bt = bt->next;
return bt;
}
@ -620,7 +620,6 @@ int read_borders(gamedata *data)
assert(type || !"connection type not registered");
}
READ_INT(store, &bid);
if (data->version < UIDHASH_VERSION) {
int fx, fy, tx, ty;
@ -639,9 +638,7 @@ int read_borders(gamedata *data)
to = findregionbyid(tid);
}
if (!to || !from) {
if (!to || !from) {
log_error("%s connection %d has missing regions", zText, bid);
}
log_error("%s connection %d has missing regions", zText, bid);
if (type->read) {
// skip ahead
connection dummy;
@ -650,7 +647,7 @@ int read_borders(gamedata *data)
continue;
}
if (to == from && type && from) {
if (to == from && from) {
direction_t dir = (direction_t)(rng_int() % MAXDIRECTIONS);
region *r = rconnect(from, dir);
log_error("[read_borders] invalid %s in %s\n", type->__name, regionname(from, NULL));
@ -659,7 +656,7 @@ int read_borders(gamedata *data)
}
if (type->read) {
connection *b = new_border(type, from, to);
nextborder--; /* new_border erhöht den Wert */
nextborder--; /* new_border erh<EFBFBD>ht den Wert */
b->id = bid;
assert(bid <= nextborder);
type->read(b, data);

View file

@ -796,7 +796,7 @@ static void json_settings(cJSON *json) {
else {
char value[32];
if (child->type == cJSON_Number && child->valuedouble && child->valueint<child->valuedouble) {
_snprintf(value, sizeof(value), "%lf", child->valuedouble);
_snprintf(value, sizeof(value), "%f", child->valuedouble);
}
else {
_snprintf(value, sizeof(value), "%d", child->valueint);

View file

@ -297,10 +297,9 @@ int crew_skill(const ship *sh) {
int shipspeed(const ship * sh, const unit * u)
{
int k = sh->type->range;
attrib *a;
struct curse *c;
int bonus;
int k, bonus;
assert(sh);
if (!u) u = ship_owner(sh);
@ -310,6 +309,7 @@ int shipspeed(const ship * sh, const unit * u)
assert(sh->type->construction);
assert(sh->type->construction->improvement == NULL); /* sonst ist construction::size nicht ship_type::maxsize */
k = sh->type->range;
if (sh->size != sh->type->construction->maxsize)
return 0;
@ -417,7 +417,7 @@ static unit * ship_owner_ex(const ship * sh, const struct faction * last_owner)
{
unit *u, *heir = 0;
/* Eigentümer tot oder kein Eigentümer vorhanden. Erste lebende Einheit
/* Eigent<EFBFBD>mer tot oder kein Eigent<6E>mer vorhanden. Erste lebende Einheit
* nehmen. */
for (u = sh->region->units; u; u = u->next) {
if (u->ship == sh) {

View file

@ -273,10 +273,10 @@ void setup_drift (struct drift_fixture *fix) {
fix->st_boat->cabins = 20000;
fix->u = test_create_unit(fix->f = test_create_faction(0), fix->r=findregion(-1,0));
assert(fix->r);
assert(fix->r && fix->u && fix->f);
set_level(fix->u, SK_SAILING, fix->st_boat->sumskill);
u_set_ship(fix->u, fix->sh = test_create_ship(fix->u->region, fix->st_boat));
assert(fix->f && fix->u && fix->sh);
assert(fix->sh);
}
static void test_ship_no_overload(CuTest *tc) {

View file

@ -83,12 +83,12 @@ static void test_piracy_cmd(CuTest * tc) {
t_ocean = get_or_create_terrain("ocean");
st_boat = st_get_or_create("boat");
u2 = test_create_unit(test_create_faction(0), test_create_region(1, 0, t_ocean));
u_set_ship(u2, test_create_ship(u2->region, st_boat));
assert(u2);
u_set_ship(u2, test_create_ship(u2->region, st_boat));
u = test_create_unit(f = test_create_faction(0), r = test_create_region(0, 0, t_ocean));
assert(f && u);
set_level(u, SK_SAILING, st_boat->sumskill);
u_set_ship(u, test_create_ship(u->region, st_boat));
assert(f && u);
f->locale = get_or_create_locale("de");
u->thisorder = create_order(K_PIRACY, f->locale, "%s", itoa36(u2->faction->no));

View file

@ -489,13 +489,14 @@ size_t size)
building *b;
bool isbattle = (bool)(mode == seen_battle);
item *itm, *show = NULL;
faction *fv = visible_faction(f, u);
faction *fv;
char *bufp = buf;
int result = 0;
item results[MAX_INVENTORY];
assert(f);
bufp = STRLCPY(bufp, unitname(u), size);
fv = visible_faction(f, u);
if (!isbattle) {
attrib *a_otherfaction = a_find(u->attribs, &at_otherfaction);
if (u->faction == f) {
@ -770,7 +771,7 @@ size_t size)
}
dh = 0;
if (!getarnt && f) {
if (!getarnt) {
if (alliedfaction(rplane(u->region), f, fv, HELP_ALL)) {
dh = 1;
}

View file

@ -81,10 +81,11 @@ void test_upkeep_from_pool(CuTest * tc)
i_silver = it_find("money");
assert(i_silver);
r = findregion(0, 0);
assert(r);
u1 = test_create_unit(test_create_faction(test_create_race("human")), r);
assert(u1);
u2 = test_create_unit(u1->faction, r);
assert(r && u1 && u2);
assert(u2);
config_set("rules.food.flags", "0");
i_change(&u1->items, i_silver, 30);