get rid of new coverity scan warnings

This commit is contained in:
Enno Rehling 2021-06-20 00:18:36 +02:00
parent 3e3597e99f
commit d5d0617090
2 changed files with 11 additions and 6 deletions

View File

@ -29,8 +29,10 @@ void write_triggers(struct storage *store, const trigger * t)
int read_triggers(struct gamedata *data, trigger ** tp) int read_triggers(struct gamedata *data, trigger ** tp)
{ {
assert(*tp == NULL);
for (;;) { for (;;) {
trigger_type *ttype; trigger_type *ttype;
trigger *tr;
char zText[128]; char zText[128];
READ_TOK(data->store, zText, sizeof(zText)); READ_TOK(data->store, zText, sizeof(zText));
@ -38,19 +40,22 @@ int read_triggers(struct gamedata *data, trigger ** tp)
break; break;
ttype = tt_find(zText); ttype = tt_find(zText);
assert(ttype || !"unknown trigger-type"); assert(ttype || !"unknown trigger-type");
*tp = t_new(ttype); tr = t_new(ttype);
assert(tr->next == NULL);
if (ttype->read) { if (ttype->read) {
int i = ttype->read(*tp, data); int i = ttype->read(*tp, data);
switch (i) { switch (i) {
case AT_READ_OK: case AT_READ_OK:
tp = &(*tp)->next; *tp = tr;
tp = &tr->next;
break; break;
case AT_READ_FAIL: case AT_READ_FAIL:
t_free(*tp); t_free(tr);
free(*tp); free(tr);
*tp = NULL;
break; break;
default: default:
t_free(tr);
free(tr);
assert(!"invalid return value"); assert(!"invalid return value");
break; break;
} }

View File

@ -1184,7 +1184,7 @@ int sp_appeasement(struct castorder * co)
/* Fliehende Einheiten verlassen auf jeden Fall Gebaeude und Schiffe. */ /* Fliehende Einheiten verlassen auf jeden Fall Gebaeude und Schiffe. */
if (!(r->terrain->flags & SEA_REGION)) { if (!(r->terrain->flags & SEA_REGION)) {
leave(mage, false); (void)leave(mage, false);
} }
/* und bewachen nicht */ /* und bewachen nicht */
setguard(mage, false); setguard(mage, false);