From 0c29dd2a524aab48238926e4a893ea406a851971 Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Wed, 20 Sep 2006 19:00:34 +0000 Subject: [PATCH] allow gcc to still do the bounds checking --- src/setup.c | 4 ++-- src/sst.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/setup.c b/src/setup.c index e4ee63d..e0ca59d 100644 --- a/src/setup.c +++ b/src/setup.c @@ -175,8 +175,8 @@ static void setup_names(void) /* Sets up some arrays with localized names. * Must be done after iostart() for localization to work. */ { - char *tmp1[] = SYSTEM_NAMES; - char *tmp2[] = DEVICE_NAMES; + char *tmp1[ARRAY_SIZE(systnames)] = SYSTEM_NAMES; + char *tmp2[ARRAY_SIZE(device)] = DEVICE_NAMES; memcpy(systnames, tmp1, sizeof(systnames)); memcpy(device, tmp2, sizeof(device)); diff --git a/src/sst.h b/src/sst.h index 83e7455..2e6f909 100644 --- a/src/sst.h +++ b/src/sst.h @@ -203,6 +203,8 @@ extern double scheduled(int); #define SSTMAGIC "SST2.0\n" +#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) + struct game { char magic[sizeof(SSTMAGIC)]; unsigned long options; -- 2.31.1