From 7158f609c94d006cbb2af24558401628cd1baebd Mon Sep 17 00:00:00 2001 From: Aaron Durbin Date: Wed, 13 Aug 2014 15:25:55 -0500 Subject: [PATCH] tegra132: provide more robust array bounds checking Make sure the array size matches the number of supported FUNITs. Also remove the FUNIT_NONE enumeration so that there isn't an empty slot in the array at index 0. BUG=chrome-os-partner:31251 BRANCH=None TEST=Built when array wasn't large enough. Compiler threw an error. Change-Id: I1b83ddff799a56ea39efa23a91dca1a9e0f10862 Signed-off-by: Patrick Georgi Original-Commit-Id: 4cbe74905bbeb815e9f20bcc0fad3751a3133b04 Original-Change-Id: I0bb37c51311d202729b7fb9731d6eec0a28dc040 Original-Signed-off-by: Aaron Durbin Original-Reviewed-on: https://chromium-review.googlesource.com/212330 Original-Reviewed-by: Furquan Shaikh Reviewed-on: http://review.coreboot.org/8935 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer --- src/soc/nvidia/tegra132/funitcfg.c | 2 ++ src/soc/nvidia/tegra132/include/soc/funitcfg.h | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/soc/nvidia/tegra132/funitcfg.c b/src/soc/nvidia/tegra132/funitcfg.c index 6d4cd2b6fd..e89670bfdf 100644 --- a/src/soc/nvidia/tegra132/funitcfg.c +++ b/src/soc/nvidia/tegra132/funitcfg.c @@ -82,6 +82,8 @@ static const struct funit_cfg_data funit_data[] = { FUNIT_DATA(SDMMC3, sdmmc3, U), FUNIT_DATA(SDMMC4, sdmmc4, L), }; +_Static_assert(ARRAY_SIZE(funit_data) == FUNIT_INDEX_MAX, + "funit_cfg_data array not filled out!"); static inline uint32_t get_clk_src_freq(uint32_t clk_src) { diff --git a/src/soc/nvidia/tegra132/include/soc/funitcfg.h b/src/soc/nvidia/tegra132/include/soc/funitcfg.h index ac7f7f95d7..0bb20a537d 100644 --- a/src/soc/nvidia/tegra132/include/soc/funitcfg.h +++ b/src/soc/nvidia/tegra132/include/soc/funitcfg.h @@ -28,7 +28,6 @@ #define FUNIT_INDEX(_name) FUNIT_##_name enum { - FUNIT_NONE = 0, FUNIT_INDEX(SBC1), FUNIT_INDEX(SBC4), FUNIT_INDEX(I2C2),