diff options
author | Bill Richardson <wfrichar@chromium.org> | 2013-07-30 17:26:20 -0700 |
---|---|---|
committer | ChromeBot <chrome-bot@google.com> | 2013-07-31 12:33:31 -0700 |
commit | af777297370e971bd4ae64e0e947cb5a1774dbfe (patch) | |
tree | 282a090d2431626ce01e4940c4a4ca722d70166e /board/puppy | |
parent | f6799258c3842ef855bf1516066464431b1b1a7d (diff) | |
download | chrome-ec-af777297370e971bd4ae64e0e947cb5a1774dbfe.tar.gz |
Add build-time checks on board-specific array sizes.
We've been declaring a bunch of statically-sized arrays:
extern struct foo_t foo[FOO_COUNT];
And then initializing them like so:
struct foo_t foo[FOO_COUNT] = {
/* blah */
};
That only catches cases where we initialize with too many entries. It
doesn't catch cases where we haven't initialized enough. This change tests
for both cases like so:
extern struct foo_t foo[];
struct foo_t foo[] = {
/* blah */
};
BUILD_ASSERT(ARRAY_SIZE(foo) == FOO_COUNT);
The affected arrays are:
adc_channels[ADC_CH_COUNT]
gpio_list[GPIO_COUNT]
temp_sensors[TEMP_SENSOR_COUNT]
x86_signal_list[X86_SIGNAL_COUNT]
i2c_ports[I2C_PORTS_USED]
BUG=chrome-os-partner:18343
BRANCH=falco,peppy
TEST=build all platforms
All platforms should still build, all tests should still pass.
Change-Id: Ibb16dc3201f32df7cdc875648e89ba4ffb09f733
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63833
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'board/puppy')
-rw-r--r-- | board/puppy/board.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/board/puppy/board.c b/board/puppy/board.c index 607a94b7fc..0bb2eb3a6c 100644 --- a/board/puppy/board.c +++ b/board/puppy/board.c @@ -22,7 +22,7 @@ #define GPIO_KB_OUTPUT GPIO_ODR_HIGH /* GPIO signal list. Must match order from enum gpio_signal. */ -const struct gpio_info gpio_list[GPIO_COUNT] = { +const struct gpio_info gpio_list[] = { /* Inputs with interrupt handlers are first for efficiency */ {"KB_PWR_ON_L", GPIO_B, (1<<5), GPIO_INT_BOTH, gaia_power_event}, {"PP1800_LDO2", GPIO_A, (1<<1), GPIO_INT_BOTH, gaia_power_event}, @@ -80,6 +80,7 @@ const struct gpio_info gpio_list[GPIO_COUNT] = { {"KB_OUT11", GPIO_C, (1<<4), GPIO_KB_OUTPUT, NULL}, {"KB_OUT12", GPIO_A, (1<<13), GPIO_KB_OUTPUT, NULL}, }; +BUILD_ASSERT(ARRAY_SIZE(gpio_list) == GPIO_COUNT); /* Battery temperature ranges in degrees C */ const struct battery_temperature_ranges bat_temp_ranges = { @@ -92,9 +93,10 @@ const struct battery_temperature_ranges bat_temp_ranges = { }; /* I2C ports */ -const struct i2c_port_t i2c_ports[I2C_PORTS_USED] = { +const struct i2c_port_t i2c_ports[] = { {"host", I2C_PORT_HOST, 100}, }; +BUILD_ASSERT(ARRAY_SIZE(i2c_ports) == I2C_PORTS_USED); void board_config_post_gpio_init(void) { |