Fix empdump to check for truncation failure

xubody() neglected to check ef_truncate()'s return value.  Two failure
modes: invalid arguments, and ftruncate() failure.  The former
shouldn't happen, and the latter can happen only for file-backed
tables, hence only in empdump -i.
This commit is contained in:
Markus Armbruster 2011-05-07 21:05:02 +02:00
parent 5cedc533f8
commit 7e95b52bce

View file

@ -996,9 +996,10 @@ xubody(FILE *fp)
maxid = ep->fids; maxid = ep->fids;
if (maxid < ep->fids) { if (maxid < ep->fids) {
if (EF_IS_GAME_STATE(cur_type) if (EF_IS_GAME_STATE(cur_type)
|| (cur_type >= EF_SHIP_CHR && cur_type <= EF_NUKE_CHR)) || (cur_type >= EF_SHIP_CHR && cur_type <= EF_NUKE_CHR)) {
ef_truncate(cur_type, maxid); if (!ef_truncate(cur_type, maxid))
else return -1;
} else
return gripe("Table %s requires %d rows, got %d", return gripe("Table %s requires %d rows, got %d",
ef_nameof(cur_type), ep->fids, maxid); ef_nameof(cur_type), ep->fids, maxid);
} }