From 2fb228c198d2581df4c90bd94f0240737a9db134 Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Mon, 7 Oct 2013 13:20:58 -0700 Subject: cleanup: Don't use [N] = {} when initializing arrays If we do this: enum foo_v { FOO_A, FOO_B, FOO_COUNT }; struct foo_t foo[] = { {...}, {...}, }; BUILD_ASSERT(ARRAY_SIZE(foo) == FOO_COUNT); Then we can be sure we're at least initialized all the elements of foo, although there's no particular guarantee that the order is correct. However, if we use this: struct foo_t foo[] = { [FOO_A] = {...}, [FOO_B] = {...}, }; and we accidentally get one wrong: struct foo_t foo[] = { [FOO_B] = {...}, [FOO_B] = {...}, }; Then the assertion still passes, but we've only initialized one element. Don't do that. BUG=chrome-os-partner:18343 BRANCH=none TEST=manual Refactoring only. Build everything. It should still work. Change-Id: I58f659207990f18c6fb74b1cac2ec1163cdb07ea Signed-off-by: Bill Richardson Reviewed-on: https://chromium-review.googlesource.com/172115 Reviewed-by: Randall Spangler --- board/spring/board.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'board/spring') diff --git a/board/spring/board.c b/board/spring/board.c index fd9acaf6d5..09e943d8f7 100644 --- a/board/spring/board.c +++ b/board/spring/board.c @@ -120,10 +120,9 @@ const struct adc_t adc_channels[] = { }; BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT); -/* PWM channels */ +/* PWM channels. Must be in the exactly same order as in enum pwm_channel. */ const struct pwm_t pwm_channels[] = { - [PWM_CH_ILIM] = {STM32_TIM(3), STM32_TIM_CH(1), 0, - GPIO_ILIM}, + {STM32_TIM(3), STM32_TIM_CH(1), 0, GPIO_ILIM}, }; BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); -- cgit v1.2.1