From de4dda6ef1d989e78b47c0157e5f7f81efb557f4 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 10 Sep 2022 05:53:38 +0300 Subject: [PATCH 14/31] city_choose_build_default(): Fix dead assignment on NDEBUG build See osdn #45633 Signed-off-by: Marko Lindqvist --- common/city.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/common/city.c b/common/city.c index 9a8685d43b..67de67c2ff 100644 --- a/common/city.c +++ b/common/city.c @@ -1080,24 +1080,26 @@ void city_choose_build_default(struct city *pcity) bool found = FALSE; /* Just pick the first available item. */ - improvement_iterate(pimprove) { - if (can_city_build_improvement_direct(pcity, pimprove)) { - found = TRUE; - pcity->production.kind = VUT_IMPROVEMENT; - pcity->production.value.building = pimprove; - break; - } + if (can_city_build_improvement_direct(pcity, pimprove)) { + found = TRUE; + pcity->production.kind = VUT_IMPROVEMENT; + pcity->production.value.building = pimprove; + break; + } } improvement_iterate_end; if (!found) { - unit_type_iterate(punittype) { - if (can_city_build_unit_direct(pcity, punittype)) { - found = TRUE; - pcity->production.kind = VUT_UTYPE; - pcity->production.value.utype = punittype; - } - } unit_type_iterate_end; + unit_type_iterate(punittype) { + if (can_city_build_unit_direct(pcity, punittype)) { +#ifndef FREECIV_NDEBUG + /* Later than this, 'found' is only needed in an fc_assert() */ + found = TRUE; +#endif /* FREECIV_NDEBUG */ + pcity->production.kind = VUT_UTYPE; + pcity->production.value.utype = punittype; + } + } unit_type_iterate_end; } fc_assert_msg(found, "No production found for city %s!", -- 2.35.1