From: Stas Sergeev Date: Wed, 20 Sep 2006 19:00:34 +0000 (+0000) Subject: allow gcc to still do the bounds checking X-Git-Tag: 2.0~208 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=0c29dd2a524aab48238926e4a893ea406a851971;p=super-star-trek.git allow gcc to still do the bounds checking --- 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;