Merge pull request #380 from ennorehling/develop

division by zero errors, coverity
This commit is contained in:
Enno Rehling 2015-11-09 18:27:09 +01:00
commit 83c607a403
2 changed files with 4 additions and 4 deletions

View File

@ -96,8 +96,8 @@ void do_markets(void)
const struct race *rc = f ? f->race : NULL; const struct race *rc = f ? f->race : NULL;
int p = rpeasants(r); int p = rpeasants(r);
int numlux = rc_luxury_trade(rc), numherbs = rc_herb_trade(rc); int numlux = rc_luxury_trade(rc), numherbs = rc_herb_trade(rc);
numlux = (p + numlux - MIN_PEASANTS) / numlux; if (numlux>0) numlux = (p + numlux - MIN_PEASANTS) / numlux;
numherbs = (p + numherbs - MIN_PEASANTS) / numherbs; if (numherbs>0) numherbs = (p + numherbs - MIN_PEASANTS) / numherbs;
if (numlux > 0 || numherbs > 0) { if (numlux > 0 || numherbs > 0) {
int d, nmarkets = 0; int d, nmarkets = 0;
const item_type *lux = r_luxury(r); const item_type *lux = r_luxury(r);

View File

@ -1541,8 +1541,8 @@ static void prepare_report(struct report_context *ctx, faction *f)
} }
static void mkreportdir(const char *rpath) { static void mkreportdir(const char *rpath) {
if (_access(rpath, 0) < 0) { if (_mkdir(rpath) != 0) {
if (_mkdir(rpath) != 0) { if (_access(rpath, 0) < 0) {
log_error("could not create reports directory %s: %s", rpath, strerror(errno)); log_error("could not create reports directory %s: %s", rpath, strerror(errno));
abort(); abort();
} }