From b90ccf4c1a8fe8b12d70e0b0e026e3c782f4ba75 Mon Sep 17 00:00:00 2001 From: Michael Hope Date: Fri, 22 May 2015 05:28:06 +0200 Subject: [PATCH] various: use ARRAYLEN() in more places. Signed-off-by: Michael Hope --- src/main/drivers/light_led_stm32f10x.c | 4 +++- src/main/drivers/light_led_stm32f30x.c | 2 +- src/main/io/gps.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/drivers/light_led_stm32f10x.c b/src/main/drivers/light_led_stm32f10x.c index 45fc55d466..383818e3f5 100644 --- a/src/main/drivers/light_led_stm32f10x.c +++ b/src/main/drivers/light_led_stm32f10x.c @@ -21,6 +21,8 @@ #include "platform.h" +#include "common/utils.h" + #include "system.h" #include "gpio.h" @@ -56,7 +58,7 @@ void ledInit(void) #endif }; - uint8_t gpio_count = sizeof(gpio_setup) / sizeof(gpio_setup[0]); + uint8_t gpio_count = ARRAYLEN(gpio_setup); #ifdef LED0 RCC_APB2PeriphClockCmd(LED0_PERIPHERAL, ENABLE); diff --git a/src/main/drivers/light_led_stm32f30x.c b/src/main/drivers/light_led_stm32f30x.c index 90b4a56c9e..4b22beb382 100644 --- a/src/main/drivers/light_led_stm32f30x.c +++ b/src/main/drivers/light_led_stm32f30x.c @@ -47,7 +47,7 @@ void ledInit(void) #endif }; - uint8_t gpio_count = sizeof(gpio_setup) / sizeof(gpio_setup[0]); + uint8_t gpio_count = ARRAYLEN(gpio_setup); #ifdef LED0 RCC_AHBPeriphClockCmd(LED0_PERIPHERAL, ENABLE); diff --git a/src/main/io/gps.c b/src/main/io/gps.c index f34008a697..a1f66698ce 100644 --- a/src/main/io/gps.c +++ b/src/main/io/gps.c @@ -28,6 +28,7 @@ #include "common/maths.h" #include "common/axis.h" +#include "common/utils.h" #include "drivers/system.h" #include "drivers/serial.h" @@ -185,7 +186,7 @@ static void shiftPacketLog(void) { uint32_t i; - for (i = sizeof(gpsPacketLog) - 1; i > 0 ; i--) { + for (i = ARRAYLEN(gpsPacketLog) - 1; i > 0 ; i--) { gpsPacketLog[i] = gpsPacketLog[i-1]; } }