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 /include | |
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 'include')
-rw-r--r-- | include/gpio.h | 2 | ||||
-rw-r--r-- | include/i2c.h | 2 | ||||
-rw-r--r-- | include/temp_sensor.h | 2 |
3 files changed, 4 insertions, 2 deletions
diff --git a/include/gpio.h b/include/gpio.h index b66b4be794..9517cf40ee 100644 --- a/include/gpio.h +++ b/include/gpio.h @@ -51,7 +51,7 @@ struct gpio_info { }; /* Signal information from board.c. Must match order from enum gpio_signal. */ -extern const struct gpio_info gpio_list[GPIO_COUNT]; +extern const struct gpio_info gpio_list[]; /* Macro for signals which don't exist */ #ifdef CHIP_lm4 diff --git a/include/i2c.h b/include/i2c.h index 86535c1fa8..747967b3a6 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -20,6 +20,8 @@ struct i2c_port_t { int kbps; /* Speed in kbps */ }; +extern const struct i2c_port_t i2c_ports[]; + /* Flags for i2c_xfer() */ #define I2C_XFER_START (1 << 0) /* Start smbus session from idle state */ #define I2C_XFER_STOP (1 << 1) /* Terminate smbus session with stop bit */ diff --git a/include/temp_sensor.h b/include/temp_sensor.h index d3532426e6..c4943dda38 100644 --- a/include/temp_sensor.h +++ b/include/temp_sensor.h @@ -45,7 +45,7 @@ struct temp_sensor_t { * Defined in board_temp_sensor.c. Must be in the same order as * in enum temp_sensor_id. */ -extern const struct temp_sensor_t temp_sensors[TEMP_SENSOR_COUNT]; +extern const struct temp_sensor_t temp_sensors[]; #endif /** |