From eb95613996d5605716ab5158371d6d0baa920a52 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 25 Aug 2019 18:14:03 +0200 Subject: [PATCH] fix gcc issues with new season_t type. --- src/jsonconf.c | 2 +- src/jsonconf.test.c | 4 ++-- src/kernel/calendar.h | 2 +- src/kernel/calendar.test.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/jsonconf.c b/src/jsonconf.c index 06ea2c786..fdcae9f25 100644 --- a/src/jsonconf.c +++ b/src/jsonconf.c @@ -792,7 +792,7 @@ static void json_calendar(cJSON *json) { for (i = 0, jmonth = child->child; jmonth; jmonth = jmonth->next, ++i) { if (jmonth->type == cJSON_Object) { storms[i] = cJSON_GetObjectItem(jmonth, "storm")->valueint; - month_season[i] = cJSON_GetObjectItem(jmonth, "season")->valueint; + month_season[i] = (season_t) cJSON_GetObjectItem(jmonth, "season")->valueint; } else { log_error("calendar.months[%d] is not an object: %d", i, json->type); diff --git a/src/jsonconf.test.c b/src/jsonconf.test.c index 1fc27d3e6..491668506 100644 --- a/src/jsonconf.test.c +++ b/src/jsonconf.test.c @@ -160,8 +160,8 @@ static void test_calendar(CuTest * tc) CuAssertIntEquals(tc, 99, storms[0]); CuAssertIntEquals(tc, 22, storms[1]); CuAssertPtrNotNull(tc, month_season); - CuAssertIntEquals(tc, 1, month_season[0]); - CuAssertIntEquals(tc, 2, month_season[1]); + CuAssertIntEquals(tc, SEASON_SPRING, month_season[0]); + CuAssertIntEquals(tc, SEASON_SUMMER, month_season[1]); cJSON_Delete(json); test_teardown(); } diff --git a/src/kernel/calendar.h b/src/kernel/calendar.h index d1a82f037..e0b7eb873 100644 --- a/src/kernel/calendar.h +++ b/src/kernel/calendar.h @@ -15,7 +15,7 @@ extern "C" { extern const char *seasonnames[CALENDAR_SEASONS]; extern int months_per_year; - extern int *month_season; + extern season_t *month_season; extern int first_month; extern int turn; diff --git a/src/kernel/calendar.test.c b/src/kernel/calendar.test.c index 1a951efb3..75806e8e6 100644 --- a/src/kernel/calendar.test.c +++ b/src/kernel/calendar.test.c @@ -71,7 +71,7 @@ static void setup_calendar() { months_per_year = 4; weeks_per_month = 2; free(month_season); - month_season = calloc(months_per_year, sizeof(int)); + month_season = calloc(months_per_year, sizeof(season_t)); for (i = 0; i != 4; ++i) { month_season[i] = (season_t)i; }