diff --git a/sys/arduino/base.cpp b/sys/arduino/base.cpp index 65f6a450c0..41df7b7534 100644 --- a/sys/arduino/base.cpp +++ b/sys/arduino/base.cpp @@ -26,7 +26,7 @@ extern "C" { #include "arduino.hpp" -#define ANALOG_PIN_NUMOF (sizeof(arduino_analog_map) / sizeof(arduino_analog_map[0])) +#define ANALOG_PIN_NUMOF (ARRAY_SIZE(arduino_analog_map)) void pinMode(int pin, int mode) { diff --git a/sys/auto_init/can/auto_init_can_native.c b/sys/auto_init/can/auto_init_can_native.c index 320ed576be..ac70361901 100644 --- a/sys/auto_init/can/auto_init_can_native.c +++ b/sys/auto_init/can/auto_init_can_native.c @@ -20,7 +20,7 @@ #include "can/device.h" #include "candev_linux_params.h" -#define CANDEV_LINUX_NUMOF ((sizeof(candev_linux_params) / sizeof(candev_params_t))) +#define CANDEV_LINUX_NUMOF ARRAY_SIZE(candev_linux_params) #ifndef CANDEV_LINUX_STACKSIZE #define CANDEV_LINUX_STACKSIZE (THREAD_STACKSIZE_DEFAULT + THREAD_EXTRA_STACKSIZE_PRINTF) diff --git a/sys/auto_init/can/auto_init_periph_can.c b/sys/auto_init/can/auto_init_periph_can.c index 5f30c9f068..0b361ffa20 100644 --- a/sys/auto_init/can/auto_init_periph_can.c +++ b/sys/auto_init/can/auto_init_periph_can.c @@ -20,7 +20,7 @@ #include "can/device.h" #include "can_params.h" -#define CANDEV_NUMOF ((sizeof(candev_params) / sizeof(candev_params[0]))) +#define CANDEV_NUMOF (ARRAY_SIZE(candev_params)) #ifndef CANDEV_STACKSIZE #define CANDEV_STACKSIZE (THREAD_STACKSIZE_DEFAULT + THREAD_EXTRA_STACKSIZE_PRINTF) diff --git a/sys/auto_init/netif/auto_init_at86rf2xx.c b/sys/auto_init/netif/auto_init_at86rf2xx.c index 256733b9e7..88b0767290 100644 --- a/sys/auto_init/netif/auto_init_at86rf2xx.c +++ b/sys/auto_init/netif/auto_init_at86rf2xx.c @@ -42,7 +42,7 @@ #define AT86RF2XX_MAC_PRIO (GNRC_NETIF_PRIO) #endif -#define AT86RF2XX_NUM (sizeof(at86rf2xx_params) / sizeof(at86rf2xx_params[0])) +#define AT86RF2XX_NUM ARRAY_SIZE(at86rf2xx_params) static at86rf2xx_t at86rf2xx_devs[AT86RF2XX_NUM]; static char _at86rf2xx_stacks[AT86RF2XX_NUM][AT86RF2XX_MAC_STACKSIZE]; diff --git a/sys/auto_init/netif/auto_init_cc110x.c b/sys/auto_init/netif/auto_init_cc110x.c index 3378600474..7a0e9df67e 100644 --- a/sys/auto_init/netif/auto_init_cc110x.c +++ b/sys/auto_init/netif/auto_init_cc110x.c @@ -38,7 +38,7 @@ #define CC110X_MAC_PRIO (GNRC_NETIF_PRIO) #endif -#define CC110X_NUM (sizeof(cc110x_params)/sizeof(cc110x_params[0])) +#define CC110X_NUM ARRAY_SIZE(cc110x_params) static netdev_cc110x_t cc110x_devs[CC110X_NUM]; static char _stacks[CC110X_NUM][CC110X_MAC_STACKSIZE]; diff --git a/sys/auto_init/netif/auto_init_cc2420.c b/sys/auto_init/netif/auto_init_cc2420.c index b37f687172..a53287a0a5 100644 --- a/sys/auto_init/netif/auto_init_cc2420.c +++ b/sys/auto_init/netif/auto_init_cc2420.c @@ -42,7 +42,7 @@ /** * @brief Get the number of configured CC2420 devices */ -#define CC2420_NUMOF (sizeof(cc2420_params) / sizeof(cc2420_params[0])) +#define CC2420_NUMOF ARRAY_SIZE(cc2420_params) /** * @brief Allocate memory for dev descriptors, stacks, and 802.15.4 adaption diff --git a/sys/auto_init/netif/auto_init_enc28j60.c b/sys/auto_init/netif/auto_init_enc28j60.c index 0e8c00d280..878984697e 100644 --- a/sys/auto_init/netif/auto_init_enc28j60.c +++ b/sys/auto_init/netif/auto_init_enc28j60.c @@ -39,7 +39,7 @@ /** * @brief Find out how many of these devices we need to care for */ -#define ENC28J60_NUM (sizeof(enc28j60_params) / sizeof(enc28j60_params[0])) +#define ENC28J60_NUM ARRAY_SIZE(enc28j60_params) /** * @brief Allocate memory for the device descriptors diff --git a/sys/auto_init/netif/auto_init_kw2xrf.c b/sys/auto_init/netif/auto_init_kw2xrf.c index adbbc5f23e..83c79296b4 100644 --- a/sys/auto_init/netif/auto_init_kw2xrf.c +++ b/sys/auto_init/netif/auto_init_kw2xrf.c @@ -39,7 +39,7 @@ #define KW2XRF_MAC_PRIO (GNRC_NETIF_PRIO) #endif -#define KW2XRF_NUM (sizeof(kw2xrf_params)/sizeof(kw2xrf_params[0])) +#define KW2XRF_NUM ARRAY_SIZE(kw2xrf_params) static kw2xrf_t kw2xrf_devs[KW2XRF_NUM]; static char _kw2xrf_stacks[KW2XRF_NUM][KW2XRF_MAC_STACKSIZE]; diff --git a/sys/auto_init/netif/auto_init_mrf24j40.c b/sys/auto_init/netif/auto_init_mrf24j40.c index 32d22fd01e..1bd5176d84 100644 --- a/sys/auto_init/netif/auto_init_mrf24j40.c +++ b/sys/auto_init/netif/auto_init_mrf24j40.c @@ -36,7 +36,7 @@ #define MRF24J40_MAC_PRIO (GNRC_NETIF_PRIO) #endif -#define MRF24J40_NUM (sizeof(mrf24j40_params) / sizeof(mrf24j40_params[0])) +#define MRF24J40_NUM ARRAY_SIZE(mrf24j40_params) static mrf24j40_t mrf24j40_devs[MRF24J40_NUM]; static char _mrf24j40_stacks[MRF24J40_NUM][MRF24J40_MAC_STACKSIZE]; diff --git a/sys/auto_init/netif/auto_init_slipdev.c b/sys/auto_init/netif/auto_init_slipdev.c index 4d743d832c..0e019d6be0 100644 --- a/sys/auto_init/netif/auto_init_slipdev.c +++ b/sys/auto_init/netif/auto_init_slipdev.c @@ -27,7 +27,7 @@ #include "slipdev.h" #include "slipdev_params.h" -#define SLIPDEV_NUM (sizeof(slipdev_params)/sizeof(slipdev_params_t)) +#define SLIPDEV_NUM ARRAY_SIZE(slipdev_params) /** * @brief Define stack parameters for the MAC layer thread diff --git a/sys/auto_init/netif/auto_init_sx127x.c b/sys/auto_init/netif/auto_init_sx127x.c index f3c97a39c5..d6fffebc17 100644 --- a/sys/auto_init/netif/auto_init_sx127x.c +++ b/sys/auto_init/netif/auto_init_sx127x.c @@ -30,7 +30,7 @@ /** * @brief Calculate the number of configured SX127x devices */ -#define SX127X_NUMOF (sizeof(sx127x_params) / sizeof(sx127x_params_t)) +#define SX127X_NUMOF ARRAY_SIZE(sx127x_params) /** * @brief Define stack parameters for the MAC layer thread diff --git a/sys/auto_init/netif/auto_init_w5100.c b/sys/auto_init/netif/auto_init_w5100.c index efb550b6c0..0fdcdd2b51 100644 --- a/sys/auto_init/netif/auto_init_w5100.c +++ b/sys/auto_init/netif/auto_init_w5100.c @@ -35,7 +35,7 @@ /** * @brief Find out how many of these devices we need to care for */ -#define W5100_NUM (sizeof(w5100_params) / sizeof(w5100_params[0])) +#define W5100_NUM ARRAY_SIZE(w5100_params) /** * @brief Allocate memory for the device descriptors diff --git a/sys/auto_init/netif/auto_init_xbee.c b/sys/auto_init/netif/auto_init_xbee.c index 3c64e2654a..fc52a9c1b3 100644 --- a/sys/auto_init/netif/auto_init_xbee.c +++ b/sys/auto_init/netif/auto_init_xbee.c @@ -30,7 +30,7 @@ /** * @brief Calculate the number of configured XBee devices */ -#define XBEE_NUM (sizeof(xbee_params) / sizeof(xbee_params_t)) +#define XBEE_NUM ARRAY_SIZE(xbee_params) /** * @brief Define stack parameters for the MAC layer thread diff --git a/sys/auto_init/saul/auto_init_ad7746.c b/sys/auto_init/saul/auto_init_ad7746.c index 9295107f7e..faffea0132 100644 --- a/sys/auto_init/saul/auto_init_ad7746.c +++ b/sys/auto_init/saul/auto_init_ad7746.c @@ -31,7 +31,7 @@ /** * @brief Define the number of configured sensors */ -#define AD7746_NUM (sizeof(ad7746_params) / sizeof(ad7746_params[0])) +#define AD7746_NUM ARRAY_SIZE(ad7746_params) /** * @brief Allocate memory for the device descriptors. @@ -47,7 +47,7 @@ static saul_reg_t saul_entries[AD7746_NUM * 3]; /** * @brief Define the number of saul info */ -#define AD7746_INFO_NUM (sizeof(ad7746_saul_info) / sizeof(ad7746_saul_info[0])) +#define AD7746_INFO_NUM ARRAY_SIZE(ad7746_saul_info) /** * @brief Reference the driver structs diff --git a/sys/auto_init/saul/auto_init_adc.c b/sys/auto_init/saul/auto_init_adc.c index 9bdfcf784c..3aa86cf976 100644 --- a/sys/auto_init/saul/auto_init_adc.c +++ b/sys/auto_init/saul/auto_init_adc.c @@ -30,7 +30,7 @@ /** * @brief Define the number of configured sensors */ -#define SAUL_ADC_NUMOF (sizeof(saul_adc_params)/sizeof(saul_adc_params[0])) +#define SAUL_ADC_NUMOF ARRAY_SIZE(saul_adc_params) /** * @brief Allocate memory for pointers to the ADC parameter structs diff --git a/sys/auto_init/saul/auto_init_adcxx1c.c b/sys/auto_init/saul/auto_init_adcxx1c.c index fa46cbad01..c0c12d7caf 100644 --- a/sys/auto_init/saul/auto_init_adcxx1c.c +++ b/sys/auto_init/saul/auto_init_adcxx1c.c @@ -31,7 +31,7 @@ /** * @brief Define the number of configured sensors */ -#define ADCXX1C_NUM (sizeof(adcxx1c_params) / sizeof(adcxx1c_params[0])) +#define ADCXX1C_NUM ARRAY_SIZE(adcxx1c_params) /** * @brief Allocate memory for the device descriptors @@ -46,7 +46,7 @@ static saul_reg_t saul_entries[ADCXX1C_NUM]; /** * @brief Define the number of saul info */ -#define ADCXX1C_INFO_NUM (sizeof(adcxx1c_saul_info) / sizeof(adcxx1c_saul_info[0])) +#define ADCXX1C_INFO_NUM ARRAY_SIZE(adcxx1c_saul_info) /** * @brief Reference the driver struct diff --git a/sys/auto_init/saul/auto_init_ads101x.c b/sys/auto_init/saul/auto_init_ads101x.c index 4291fc3791..3e72e51650 100644 --- a/sys/auto_init/saul/auto_init_ads101x.c +++ b/sys/auto_init/saul/auto_init_ads101x.c @@ -33,7 +33,7 @@ /** * @brief Define the number of configured sensors */ -#define ADS101X_NUM (sizeof(ads101x_params) / sizeof(ads101x_params[0])) +#define ADS101X_NUM ARRAY_SIZE(ads101x_params) /** * @brief Allocate memory for the device descriptors @@ -48,7 +48,7 @@ static saul_reg_t saul_entries[ADS101X_NUM]; /** * @brief Define the number of saul info */ -#define ADS101X_INFO_NUM (sizeof(ads101x_saul_info) / sizeof(ads101x_saul_info[0])) +#define ADS101X_INFO_NUM ARRAY_SIZE(ads101x_saul_info) /** * @brief Reference the driver struct diff --git a/sys/auto_init/saul/auto_init_adxl345.c b/sys/auto_init/saul/auto_init_adxl345.c index 46c0d4e3f9..d7df15cd7b 100644 --- a/sys/auto_init/saul/auto_init_adxl345.c +++ b/sys/auto_init/saul/auto_init_adxl345.c @@ -30,7 +30,7 @@ /** * @brief Define the number of configured sensors */ -#define ADXL345_NUM (sizeof(adxl345_params) / sizeof(adxl345_params[0])) +#define ADXL345_NUM ARRAY_SIZE(adxl345_params) /** * @brief Allocate memory for the device descriptors @@ -45,7 +45,7 @@ static saul_reg_t saul_entries[ADXL345_NUM]; /** * @brief Define the number of saul info */ -#define ADXL345_INFO_NUM (sizeof(adxl345_saul_info) / sizeof(adxl345_saul_info[0])) +#define ADXL345_INFO_NUM ARRAY_SIZE(adxl345_saul_info) /** * @brief Reference the driver structs diff --git a/sys/auto_init/saul/auto_init_bmp180.c b/sys/auto_init/saul/auto_init_bmp180.c index 0245b2a75b..be87446902 100644 --- a/sys/auto_init/saul/auto_init_bmp180.c +++ b/sys/auto_init/saul/auto_init_bmp180.c @@ -29,7 +29,7 @@ /** * @brief Define the number of configured sensors */ -#define BMP180_NUM (sizeof(bmp180_params) / sizeof(bmp180_params[0])) +#define BMP180_NUM ARRAY_SIZE(bmp180_params) /** * @brief Allocation of memory for device descriptors @@ -44,7 +44,7 @@ static saul_reg_t saul_entries[BMP180_NUM * 2]; /** * @brief Define the number of saul info */ -#define BMP180_INFO_NUM (sizeof(bmp180_saul_info) / sizeof(bmp180_saul_info[0])) +#define BMP180_INFO_NUM ARRAY_SIZE(bmp180_saul_info) /** * @name Reference the driver structs. diff --git a/sys/auto_init/saul/auto_init_bmx055.c b/sys/auto_init/saul/auto_init_bmx055.c index 02c4f65f68..053660919a 100644 --- a/sys/auto_init/saul/auto_init_bmx055.c +++ b/sys/auto_init/saul/auto_init_bmx055.c @@ -28,7 +28,7 @@ /** * @brief Define the number of configured sensors */ -#define BMX055_NUM (sizeof(bmx055_params) / sizeof(bmx055_params[0])) +#define BMX055_NUM ARRAY_SIZE(bmx055_params) /** * @brief Each sensor contains 3 individual i2c modules diff --git a/sys/auto_init/saul/auto_init_ccs811.c b/sys/auto_init/saul/auto_init_ccs811.c index f6d922225a..a587e248fe 100644 --- a/sys/auto_init/saul/auto_init_ccs811.c +++ b/sys/auto_init/saul/auto_init_ccs811.c @@ -25,7 +25,7 @@ /** * @brief Define the number of configured sensors */ -#define CCS811_NUM (sizeof(ccs811_params) / sizeof(ccs811_params[0])) +#define CCS811_NUM ARRAY_SIZE(ccs811_params) /** * @brief Allocation of memory for device descriptors @@ -40,7 +40,7 @@ static saul_reg_t saul_entries[CCS811_NUM * 2]; /** * @brief Define the number of saul info */ -#define CCS811_INFO_NUM (sizeof(ccs811_saul_info) / sizeof(ccs811_saul_info[0])) +#define CCS811_INFO_NUM ARRAY_SIZE(ccs811_saul_info) /** * @name Reference the driver structs. diff --git a/sys/auto_init/saul/auto_init_dht.c b/sys/auto_init/saul/auto_init_dht.c index 2be6677229..dbdc3ba5d4 100644 --- a/sys/auto_init/saul/auto_init_dht.c +++ b/sys/auto_init/saul/auto_init_dht.c @@ -30,7 +30,7 @@ /** * @brief Define the number of configured sensors */ -#define DHT_NUM (sizeof(dht_params) / sizeof(dht_params[0])) +#define DHT_NUM ARRAY_SIZE(dht_params) /** * @brief Allocate memory for the device descriptors @@ -45,7 +45,7 @@ static saul_reg_t saul_entries[DHT_NUM * 2]; /** * @brief Define the number of saul info */ -#define DHT_INFO_NUM (sizeof(dht_saul_info) / sizeof(dht_saul_info[0])) +#define DHT_INFO_NUM ARRAY_SIZE(dht_saul_info) /** * @name Import SAUL endpoints diff --git a/sys/auto_init/saul/auto_init_ds18.c b/sys/auto_init/saul/auto_init_ds18.c index a40dbeb4d0..3265f7a635 100644 --- a/sys/auto_init/saul/auto_init_ds18.c +++ b/sys/auto_init/saul/auto_init_ds18.c @@ -29,7 +29,7 @@ /** * @brief Define the number of configured sensors */ -#define DS18_NUMOF (sizeof(ds18_params) / sizeof(ds18_params[0])) +#define DS18_NUMOF ARRAY_SIZE(ds18_params) /** * @brief Allocation of memory for device descriptors diff --git a/sys/auto_init/saul/auto_init_ds75lx.c b/sys/auto_init/saul/auto_init_ds75lx.c index e80e273a9c..a70f05a49d 100644 --- a/sys/auto_init/saul/auto_init_ds75lx.c +++ b/sys/auto_init/saul/auto_init_ds75lx.c @@ -29,7 +29,7 @@ /** * @brief Define the number of configured sensors */ -#define DS75LX_NUM (sizeof(ds75lx_params) / sizeof(ds75lx_params[0])) +#define DS75LX_NUM ARRAY_SIZE(ds75lx_params) /** * @brief Allocation of memory for device descriptors @@ -44,7 +44,7 @@ static saul_reg_t saul_entries[DS75LX_NUM]; /** * @brief Define the number of saul info */ -#define DS75LX_INFO_NUM (sizeof(ds75lx_saul_info) / sizeof(ds75lx_saul_info[0])) +#define DS75LX_INFO_NUM ARRAY_SIZE(ds75lx_saul_info) /** * @name Reference the driver structs. diff --git a/sys/auto_init/saul/auto_init_fxos8700.c b/sys/auto_init/saul/auto_init_fxos8700.c index bbcaa1bc3c..35b600c5d9 100644 --- a/sys/auto_init/saul/auto_init_fxos8700.c +++ b/sys/auto_init/saul/auto_init_fxos8700.c @@ -28,7 +28,7 @@ /** * @brief Define the number of configured sensors */ -#define FXOS8700_NUM (sizeof(fxos8700_params)/sizeof(fxos8700_params[0])) +#define FXOS8700_NUM ARRAY_SIZE(fxos8700_params) /** * @brief Allocate memory for the device descriptors diff --git a/sys/auto_init/saul/auto_init_gpio.c b/sys/auto_init/saul/auto_init_gpio.c index 0047986462..817cf06679 100644 --- a/sys/auto_init/saul/auto_init_gpio.c +++ b/sys/auto_init/saul/auto_init_gpio.c @@ -26,6 +26,7 @@ #include "saul/periph.h" #include "gpio_params.h" #include "periph/gpio.h" +#include "kernel_defines.h" /** * @brief Define the number of configured sensors @@ -37,7 +38,7 @@ void auto_init_gpio(void) LOG_DEBUG("[auto_init_saul] no SAUL GPIO configured!\n"); } #else -#define SAUL_GPIO_NUMOF (sizeof(saul_gpio_params)/sizeof(saul_gpio_params[0])) +#define SAUL_GPIO_NUMOF ARRAY_SIZE(saul_gpio_params) /** diff --git a/sys/auto_init/saul/auto_init_grove_ledbar.c b/sys/auto_init/saul/auto_init_grove_ledbar.c index 198454bdca..34359aa721 100644 --- a/sys/auto_init/saul/auto_init_grove_ledbar.c +++ b/sys/auto_init/saul/auto_init_grove_ledbar.c @@ -31,7 +31,7 @@ /** * @brief Define the number of configured sensors */ -#define GROVE_LEDBAR_NUM (sizeof(grove_ledbar_params) / sizeof(grove_ledbar_params[0])) +#define GROVE_LEDBAR_NUM ARRAY_SIZE(grove_ledbar_params) /** * @brief Allocate memory for the device descriptors @@ -46,7 +46,7 @@ static saul_reg_t saul_entries[GROVE_LEDBAR_NUM]; /** * @brief Define the number of saul info */ -#define GROVE_LEDBAR_INFO_NUM (sizeof(grove_ledbar_saul_info) / sizeof(grove_ledbar_saul_info[0])) +#define GROVE_LEDBAR_INFO_NUM ARRAY_SIZE(grove_ledbar_saul_info) /** * @brief Reference the driver struct diff --git a/sys/auto_init/saul/auto_init_hdc1000.c b/sys/auto_init/saul/auto_init_hdc1000.c index bb443d586a..8f7ea7ae50 100644 --- a/sys/auto_init/saul/auto_init_hdc1000.c +++ b/sys/auto_init/saul/auto_init_hdc1000.c @@ -30,7 +30,7 @@ /** * @brief Define the number of configured sensors */ -#define HDC1000_NUM (sizeof(hdc1000_params) / sizeof(hdc1000_params[0])) +#define HDC1000_NUM ARRAY_SIZE(hdc1000_params) /** * @brief Allocate memory for the device descriptors @@ -45,7 +45,7 @@ static saul_reg_t saul_entries[HDC1000_NUM * 2]; /** * @brief Define the number of saul info */ -#define HDC1000_INFO_NUM (sizeof(hdc1000_saul_info) / sizeof(hdc1000_saul_info[0])) +#define HDC1000_INFO_NUM ARRAY_SIZE(hdc1000_saul_info) /** * @name Reference the driver struct diff --git a/sys/auto_init/saul/auto_init_hts221.c b/sys/auto_init/saul/auto_init_hts221.c index 119820593a..6648b593b0 100644 --- a/sys/auto_init/saul/auto_init_hts221.c +++ b/sys/auto_init/saul/auto_init_hts221.c @@ -30,9 +30,9 @@ /** * @brief Define the number of configured sensors */ -#define HTS221_NUM (sizeof(hts221_params)/sizeof(hts221_params[0])) +#define HTS221_NUM ARRAY_SIZE(hts221_params) -#define HTS221_SAUL_NUM (sizeof(hts221_saul_info)/sizeof(hts221_saul_info[0])) +#define HTS221_SAUL_NUM ARRAY_SIZE(hts221_saul_info) /** * @brief Allocate memory for the device descriptors */ diff --git a/sys/auto_init/saul/auto_init_io1_xplained.c b/sys/auto_init/saul/auto_init_io1_xplained.c index 51aede77bb..eca0aa82a3 100644 --- a/sys/auto_init/saul/auto_init_io1_xplained.c +++ b/sys/auto_init/saul/auto_init_io1_xplained.c @@ -29,7 +29,7 @@ /** * @brief Define the number of configured sensors */ -#define IO1_XPLAINED_NUM (sizeof(io1_xplained_params) / sizeof(io1_xplained_params[0])) +#define IO1_XPLAINED_NUM ARRAY_SIZE(io1_xplained_params) /** * @brief Allocation of memory for device descriptors @@ -44,7 +44,7 @@ static saul_reg_t saul_entries[IO1_XPLAINED_NUM * 4]; /** * @brief Define the number of saul info */ -#define IO1_XPLAINED_INFO_NUM (sizeof(io1_xplained_saul_info) / sizeof(io1_xplained_saul_info[0])) +#define IO1_XPLAINED_INFO_NUM ARRAY_SIZE(io1_xplained_saul_info) /** * @name Reference the driver structs. @@ -74,7 +74,7 @@ void auto_init_io1_xplained(void) /* GPIOs */ for (unsigned j = 0; - j < sizeof(io1_xplained_saul_gpios) / sizeof(io1_xplained_saul_gpios[0]); + j < ARRAY_SIZE(io1_xplained_saul_gpios); j++) { saul_reg_t *entry = &saul_entries[i * 4 + j + 1]; entry->dev = &(io1_xplained_saul_gpios[j]); diff --git a/sys/auto_init/saul/auto_init_isl29020.c b/sys/auto_init/saul/auto_init_isl29020.c index d2203da2eb..0bcb9629a0 100644 --- a/sys/auto_init/saul/auto_init_isl29020.c +++ b/sys/auto_init/saul/auto_init_isl29020.c @@ -30,7 +30,7 @@ /** * @brief Define the number of configured sensors */ -#define ISL29020_NUM (sizeof(isl29020_params) / sizeof(isl29020_params[0])) +#define ISL29020_NUM ARRAY_SIZE(isl29020_params) /** * @brief Allocate memory for the device descriptors @@ -45,7 +45,7 @@ static saul_reg_t saul_entries[ISL29020_NUM]; /** * @brief Define the number of saul info */ -#define ISL29020_INFO_NUM (sizeof(isl29020_saul_info) / sizeof(isl29020_saul_info[0])) +#define ISL29020_INFO_NUM ARRAY_SIZE(isl29020_saul_info) /** * @brief Reference the driver struct diff --git a/sys/auto_init/saul/auto_init_jc42.c b/sys/auto_init/saul/auto_init_jc42.c index f00c706132..e57a52d940 100644 --- a/sys/auto_init/saul/auto_init_jc42.c +++ b/sys/auto_init/saul/auto_init_jc42.c @@ -29,7 +29,7 @@ /** * @brief Define the number of configured sensors */ -#define JC42_NUM (sizeof(jc42_params) / sizeof(jc42_params[0])) +#define JC42_NUM ARRAY_SIZE(jc42_params) /** * @brief Allocation of memory for device descriptors @@ -44,7 +44,7 @@ static saul_reg_t saul_entries[JC42_NUM]; /** * @brief Define the number of saul info */ -#define JC42_INFO_NUM (sizeof(jc42_saul_info) / sizeof(jc42_saul_info[0])) +#define JC42_INFO_NUM ARRAY_SIZE(jc42_saul_info) /** * @brief Reference the driver structs. diff --git a/sys/auto_init/saul/auto_init_l3g4200d.c b/sys/auto_init/saul/auto_init_l3g4200d.c index 0e90cfca8a..89a32f3602 100644 --- a/sys/auto_init/saul/auto_init_l3g4200d.c +++ b/sys/auto_init/saul/auto_init_l3g4200d.c @@ -30,7 +30,7 @@ /** * @brief Define the number of configured sensors */ -#define L3G4200D_NUM (sizeof(l3g4200d_params) / sizeof(l3g4200d_params[0])) +#define L3G4200D_NUM ARRAY_SIZE(l3g4200d_params) /** * @brief Allocate memory for the device descriptors @@ -45,7 +45,7 @@ static saul_reg_t saul_entries[L3G4200D_NUM]; /** * @brief Define the number of saul info */ -#define L3G4200D_INFO_NUM (sizeof(l3g4200d_saul_info) / sizeof(l3g4200d_saul_info[0])) +#define L3G4200D_INFO_NUM ARRAY_SIZE(l3g4200d_saul_info) /** * @brief Reference the driver struct diff --git a/sys/auto_init/saul/auto_init_lis2dh12.c b/sys/auto_init/saul/auto_init_lis2dh12.c index 789e54075a..702dabb5a7 100644 --- a/sys/auto_init/saul/auto_init_lis2dh12.c +++ b/sys/auto_init/saul/auto_init_lis2dh12.c @@ -30,7 +30,7 @@ /** * @brief Number of configured sensors */ -#define LIS2DH12_NUM (sizeof(lis2dh12_params) / sizeof(lis2dh12_params[0])) +#define LIS2DH12_NUM ARRAY_SIZE(lis2dh12_params) /** diff --git a/sys/auto_init/saul/auto_init_lis3dh.c b/sys/auto_init/saul/auto_init_lis3dh.c index 813880bf1b..726cac862b 100644 --- a/sys/auto_init/saul/auto_init_lis3dh.c +++ b/sys/auto_init/saul/auto_init_lis3dh.c @@ -30,7 +30,7 @@ /** * @brief Define the number of configured sensors */ -#define LIS3DH_NUM (sizeof(lis3dh_params) / sizeof(lis3dh_params[0])) +#define LIS3DH_NUM ARRAY_SIZE(lis3dh_params) /** * @brief Allocate memory for the device descriptors @@ -45,7 +45,7 @@ static saul_reg_t saul_entries[LIS3DH_NUM]; /** * @brief Define the number of saul info */ -#define LIS3DH_INFO_NUM (sizeof(lis3dh_saul_info) / sizeof(lis3dh_saul_info[0])) +#define LIS3DH_INFO_NUM ARRAY_SIZE(lis3dh_saul_info) /** * @brief Reference the driver struct diff --git a/sys/auto_init/saul/auto_init_lis3mdl.c b/sys/auto_init/saul/auto_init_lis3mdl.c index bf1f76f0c3..009692cf4b 100644 --- a/sys/auto_init/saul/auto_init_lis3mdl.c +++ b/sys/auto_init/saul/auto_init_lis3mdl.c @@ -30,7 +30,7 @@ /** * @brief Define the number of configured sensors */ -#define LIS3MDL_NUM (sizeof(lis3mdl_params)/sizeof(lis3mdl_params[0])) +#define LIS3MDL_NUM ARRAY_SIZE(lis3mdl_params) /** * @brief Allocate memory for the device descriptors @@ -45,7 +45,7 @@ static saul_reg_t saul_entries[LIS3MDL_NUM]; /** * @brief Define the number of saul info */ -#define LIS3MDL_INFO_NUM (sizeof(lis3mdl_saul_info)/sizeof(lis3mdl_saul_info[0])) +#define LIS3MDL_INFO_NUM ARRAY_SIZE(lis3mdl_saul_info) /** * @brief Reference the driver structs diff --git a/sys/auto_init/saul/auto_init_lpsxxx.c b/sys/auto_init/saul/auto_init_lpsxxx.c index 5a190cff48..63bef7d6bb 100644 --- a/sys/auto_init/saul/auto_init_lpsxxx.c +++ b/sys/auto_init/saul/auto_init_lpsxxx.c @@ -30,7 +30,7 @@ /** * @brief Define the number of configured sensors */ -#define LPSXXX_NUM (sizeof(lpsxxx_params) / sizeof(lpsxxx_params[0])) +#define LPSXXX_NUM ARRAY_SIZE(lpsxxx_params) /** * @brief Allocate memory for the device descriptors @@ -45,7 +45,7 @@ static saul_reg_t saul_entries[LPSXXX_NUM * 2]; /** * @brief Define the number of saul info */ -#define LPSXXX_INFO_NUM (sizeof(lpsxxx_saul_info) / sizeof(lpsxxx_saul_info[0])) +#define LPSXXX_INFO_NUM ARRAY_SIZE(lpsxxx_saul_info) /** * @brief Reference the driver struct diff --git a/sys/auto_init/saul/auto_init_lsm303dlhc.c b/sys/auto_init/saul/auto_init_lsm303dlhc.c index 4eea707995..07b32b2c41 100644 --- a/sys/auto_init/saul/auto_init_lsm303dlhc.c +++ b/sys/auto_init/saul/auto_init_lsm303dlhc.c @@ -30,7 +30,7 @@ /** * @brief Define the number of configured sensors */ -#define LSM303DLHC_NUM (sizeof(lsm303dlhc_params) / sizeof(lsm303dlhc_params[0])) +#define LSM303DLHC_NUM ARRAY_SIZE(lsm303dlhc_params) /** * @brief Allocate memory for the device descriptors @@ -45,7 +45,7 @@ static saul_reg_t saul_entries[LSM303DLHC_NUM * 2]; /** * @brief Define the number of saul info */ -#define LSM303DLHC_INFO_NUM (sizeof(lsm303dlhc_saul_info) / sizeof(lsm303dlhc_saul_info[0])) +#define LSM303DLHC_INFO_NUM ARRAY_SIZE(lsm303dlhc_saul_info) /** * @name Reference the driver structs diff --git a/sys/auto_init/saul/auto_init_lsm6dsl.c b/sys/auto_init/saul/auto_init_lsm6dsl.c index b6e2969204..eaffa30e72 100644 --- a/sys/auto_init/saul/auto_init_lsm6dsl.c +++ b/sys/auto_init/saul/auto_init_lsm6dsl.c @@ -30,7 +30,7 @@ /** * @brief Define the number of configured sensors */ -#define LSM6DSL_NUM (sizeof(lsm6dsl_params) / sizeof(lsm6dsl_params[0])) +#define LSM6DSL_NUM ARRAY_SIZE(lsm6dsl_params) /** * @brief Allocate memory for the device descriptors @@ -45,7 +45,7 @@ static saul_reg_t saul_entries[LSM6DSL_NUM * 3]; /** * @brief Define the number of saul info */ -#define LSM6DSL_INFO_NUM (sizeof(lsm6dsl_saul_info) / sizeof(lsm6dsl_saul_info[0])) +#define LSM6DSL_INFO_NUM ARRAY_SIZE(lsm6dsl_saul_info) /** * @name Reference the driver structs diff --git a/sys/auto_init/saul/auto_init_ltc4150.c b/sys/auto_init/saul/auto_init_ltc4150.c index 4d967a8e72..c5a6c7df81 100644 --- a/sys/auto_init/saul/auto_init_ltc4150.c +++ b/sys/auto_init/saul/auto_init_ltc4150.c @@ -30,7 +30,7 @@ /** * @brief Define the number of configured sensors */ -#define LTC4150_NUM (sizeof(ltc4150_params) / sizeof(ltc4150_params[0])) +#define LTC4150_NUM ARRAY_SIZE(ltc4150_params) /** * @brief Allocate memory for the device descriptors @@ -45,7 +45,7 @@ static saul_reg_t saul_entries[LTC4150_NUM * 2]; /** * @brief Define the number of saul info */ -#define LTC4150_INFO_NUM (sizeof(ltc4150_saul_info) / sizeof(ltc4150_saul_info[0])) +#define LTC4150_INFO_NUM ARRAY_SIZE(ltc4150_saul_info) /** * @name Import SAUL endpoints diff --git a/sys/auto_init/saul/auto_init_mag3110.c b/sys/auto_init/saul/auto_init_mag3110.c index 5874e68f8b..8557aebcf7 100644 --- a/sys/auto_init/saul/auto_init_mag3110.c +++ b/sys/auto_init/saul/auto_init_mag3110.c @@ -31,7 +31,7 @@ /** * @brief Define the number of configured sensors */ -#define MAG3110_NUM (sizeof(mag3110_params) / sizeof(mag3110_params[0])) +#define MAG3110_NUM ARRAY_SIZE(mag3110_params) /** * @brief Allocate memory for the device descriptors @@ -46,7 +46,7 @@ static saul_reg_t saul_entries[MAG3110_NUM]; /** * @brief Define the number of saul info */ -#define MAG3110_INFO_NUM (sizeof(mag3110_saul_info) / sizeof(mag3110_saul_info[0])) +#define MAG3110_INFO_NUM ARRAY_SIZE(mag3110_saul_info) /** * @brief Reference the driver struct diff --git a/sys/auto_init/saul/auto_init_mma7660.c b/sys/auto_init/saul/auto_init_mma7660.c index f4d220b8ef..b2ba62b62d 100644 --- a/sys/auto_init/saul/auto_init_mma7660.c +++ b/sys/auto_init/saul/auto_init_mma7660.c @@ -30,7 +30,7 @@ /** * @brief Define the number of configured sensors */ -#define MMA7660_NUM (sizeof(mma7660_params) / sizeof(mma7660_params[0])) +#define MMA7660_NUM ARRAY_SIZE(mma7660_params) /** * @brief Allocate memory for the device descriptors @@ -45,7 +45,7 @@ static saul_reg_t saul_entries[MMA7660_NUM]; /** * @brief Define the number of configured sensors */ -#define MMA7660_INFO_NUM (sizeof(mma7660_saul_info) / sizeof(mma7660_saul_info[0])) +#define MMA7660_INFO_NUM ARRAY_SIZE(mma7660_saul_info) /** * @brief Reference the driver struct diff --git a/sys/auto_init/saul/auto_init_mma8x5x.c b/sys/auto_init/saul/auto_init_mma8x5x.c index 4dcc0344c4..b1c37aca00 100644 --- a/sys/auto_init/saul/auto_init_mma8x5x.c +++ b/sys/auto_init/saul/auto_init_mma8x5x.c @@ -31,7 +31,7 @@ /** * @brief Define the number of configured sensors */ -#define MMA8X5X_NUM (sizeof(mma8x5x_params) / sizeof(mma8x5x_params[0])) +#define MMA8X5X_NUM ARRAY_SIZE(mma8x5x_params) /** * @brief Allocate memory for the device descriptors @@ -46,7 +46,7 @@ static saul_reg_t saul_entries[MMA8X5X_NUM]; /** * @brief Define the number of saul info */ -#define MMA8X5X_INFO_NUM (sizeof(mma8x5x_saul_info) / sizeof(mma8x5x_saul_info[0])) +#define MMA8X5X_INFO_NUM ARRAY_SIZE(mma8x5x_saul_info) /** * @brief Reference the driver struct diff --git a/sys/auto_init/saul/auto_init_mpl3115a2.c b/sys/auto_init/saul/auto_init_mpl3115a2.c index ea113530bd..b3baf1eb4e 100644 --- a/sys/auto_init/saul/auto_init_mpl3115a2.c +++ b/sys/auto_init/saul/auto_init_mpl3115a2.c @@ -31,7 +31,7 @@ /** * @brief Define the number of configured sensors */ -#define MPL3115A2_NUM (sizeof(mpl3115a2_params) / sizeof(mpl3115a2_params[0])) +#define MPL3115A2_NUM ARRAY_SIZE(mpl3115a2_params) /** * @brief Allocate memory for the device descriptors @@ -46,7 +46,7 @@ static saul_reg_t saul_entries[MPL3115A2_NUM * 2]; /** * @brief Define the number of saul info */ -#define MPL3115A2_INFO_NUM (sizeof(mpl3115a2_saul_info) / sizeof(mpl3115a2_saul_info[0])) +#define MPL3115A2_INFO_NUM ARRAY_SIZE(mpl3115a2_saul_info) /** * @name Reference the driver struct diff --git a/sys/auto_init/saul/auto_init_mpu9150.c b/sys/auto_init/saul/auto_init_mpu9150.c index 9e6a38530f..fa0ca82ce9 100644 --- a/sys/auto_init/saul/auto_init_mpu9150.c +++ b/sys/auto_init/saul/auto_init_mpu9150.c @@ -30,7 +30,7 @@ /** * @brief Define the number of configured sensors */ -#define MPU9150_NUM (sizeof(mpu9150_params) / sizeof(mpu9150_params[0])) +#define MPU9150_NUM ARRAY_SIZE(mpu9150_params) /** * @brief Allocate memory for the device descriptors @@ -45,7 +45,7 @@ static saul_reg_t saul_entries[MPU9150_NUM * 3]; /** * @brief Define the number of saul info */ -#define MPU9150_INFO_NUM (sizeof(mpu9150_saul_info) / sizeof(mpu9150_saul_info[0])) +#define MPU9150_INFO_NUM ARRAY_SIZE(mpu9150_saul_info) /** * @name Reference the driver structs diff --git a/sys/auto_init/saul/auto_init_pir.c b/sys/auto_init/saul/auto_init_pir.c index d01b1217c6..357132b0f3 100644 --- a/sys/auto_init/saul/auto_init_pir.c +++ b/sys/auto_init/saul/auto_init_pir.c @@ -28,7 +28,7 @@ /** * @brief Define the number of configured sensors */ -#define PIR_NUM (sizeof(pir_params)/sizeof(pir_params[0])) +#define PIR_NUM ARRAY_SIZE(pir_params) /** * @brief Allocate memory for the device descriptors diff --git a/sys/auto_init/saul/auto_init_pulse_counter.c b/sys/auto_init/saul/auto_init_pulse_counter.c index b0ca423648..61f1843ad0 100644 --- a/sys/auto_init/saul/auto_init_pulse_counter.c +++ b/sys/auto_init/saul/auto_init_pulse_counter.c @@ -29,7 +29,7 @@ /** * @brief Define the number of configured sensors */ -#define PULSE_COUNTER_NUM (sizeof(pulse_counter_params) / sizeof(pulse_counter_params[0])) +#define PULSE_COUNTER_NUM ARRAY_SIZE(pulse_counter_params) /** * @brief Allocate memory for the device descriptors @@ -44,7 +44,7 @@ static saul_reg_t saul_entries[PULSE_COUNTER_NUM]; /** * @brief Define the number of configured sensors */ -#define PULSE_COUNTER_INFO_NUM (sizeof(pulse_counter_saul_info) / sizeof(pulse_counter_saul_info[0])) +#define PULSE_COUNTER_INFO_NUM ARRAY_SIZE(pulse_counter_saul_info) /** * @brief Reference the driver struct diff --git a/sys/auto_init/saul/auto_init_sds011.c b/sys/auto_init/saul/auto_init_sds011.c index f5874b6f49..a807d77c55 100644 --- a/sys/auto_init/saul/auto_init_sds011.c +++ b/sys/auto_init/saul/auto_init_sds011.c @@ -30,7 +30,7 @@ /** * @brief Define the number of configured sensors */ -#define SDS011_NUM (sizeof(sds011_params) / sizeof(sds011_params[0])) +#define SDS011_NUM ARRAY_SIZE(sds011_params) /** * @brief Allocate memory for the device descriptors @@ -45,7 +45,7 @@ static saul_reg_t saul_entries[SDS011_NUM]; /** * @brief Define the number of saul info */ -#define SDS011_INFO_NUM (sizeof(sds011_saul_info) / sizeof(sds011_saul_info[0])) +#define SDS011_INFO_NUM ARRAY_SIZE(sds011_saul_info) /** * @name Import SAUL endpoint diff --git a/sys/auto_init/saul/auto_init_sht1x.c b/sys/auto_init/saul/auto_init_sht1x.c index 4f49db3275..c4ba6261fe 100644 --- a/sys/auto_init/saul/auto_init_sht1x.c +++ b/sys/auto_init/saul/auto_init_sht1x.c @@ -36,7 +36,7 @@ /** * @brief Define the number of configured sensors */ -#define SHT1X_NUM (sizeof(sht1x_params) / sizeof(sht1x_params[0])) +#define SHT1X_NUM ARRAY_SIZE(sht1x_params) /** * @brief Allocate memory for the device descriptors diff --git a/sys/auto_init/saul/auto_init_sht3x.c b/sys/auto_init/saul/auto_init_sht3x.c index 8093166eca..5e9a90be58 100644 --- a/sys/auto_init/saul/auto_init_sht3x.c +++ b/sys/auto_init/saul/auto_init_sht3x.c @@ -24,7 +24,7 @@ /** * @brief Define the number of configured sensors */ -#define SHT3X_NUM (sizeof(sht3x_params) / sizeof(sht3x_params[0])) +#define SHT3X_NUM ARRAY_SIZE(sht3x_params) /** * @brief Allocation of memory for device descriptors @@ -39,7 +39,7 @@ static saul_reg_t saul_entries[SHT3X_NUM * 2]; /** * @brief Define the number of saul info */ -#define SHT3X_INFO_NUM (sizeof(sht3x_saul_info) / sizeof(sht3x_saul_info[0])) +#define SHT3X_INFO_NUM ARRAY_SIZE(sht3x_saul_info) /** * @name Reference the driver structs. diff --git a/sys/auto_init/saul/auto_init_si114x.c b/sys/auto_init/saul/auto_init_si114x.c index 21fe84bc56..76cc41eb6c 100644 --- a/sys/auto_init/saul/auto_init_si114x.c +++ b/sys/auto_init/saul/auto_init_si114x.c @@ -30,7 +30,7 @@ /** * @brief Define the number of configured sensors */ -#define SI114X_NUMOF (sizeof(si114x_params) / sizeof(si114x_params[0])) +#define SI114X_NUMOF ARRAY_SIZE(si114x_params) /** * @brief Allocation of memory for device descriptors @@ -45,7 +45,7 @@ static saul_reg_t saul_entries[SI114X_NUMOF * 4]; /** * @brief Define the number of saul info */ -#define SI114X_INFO_NUMOF (sizeof(si114x_saul_reg_info) / sizeof(si114x_saul_reg_info[0])) +#define SI114X_INFO_NUMOF ARRAY_SIZE(si114x_saul_reg_info) /** * @name Reference the driver structs diff --git a/sys/auto_init/saul/auto_init_si70xx.c b/sys/auto_init/saul/auto_init_si70xx.c index 609326e13d..e0b57f3d5f 100644 --- a/sys/auto_init/saul/auto_init_si70xx.c +++ b/sys/auto_init/saul/auto_init_si70xx.c @@ -29,7 +29,7 @@ /** * @brief Define the number of configured sensors */ -#define SI70XX_NUM (sizeof(si70xx_params) / sizeof(si70xx_params[0])) +#define SI70XX_NUM ARRAY_SIZE(si70xx_params) /** * @brief Allocation of memory for device descriptors @@ -44,7 +44,7 @@ static saul_reg_t saul_entries[SI70XX_NUM * 2]; /** * @brief Define the number of saul info */ -#define SI70XX_INFO_NUM (sizeof(si70xx_saul_info) / sizeof(si70xx_saul_info[0])) +#define SI70XX_INFO_NUM ARRAY_SIZE(si70xx_saul_info) /** * @name Reference the driver structs. diff --git a/sys/auto_init/saul/auto_init_tcs37727.c b/sys/auto_init/saul/auto_init_tcs37727.c index 1f3ea8018a..eab392a99a 100644 --- a/sys/auto_init/saul/auto_init_tcs37727.c +++ b/sys/auto_init/saul/auto_init_tcs37727.c @@ -30,7 +30,7 @@ /** * @brief Define the number of configured sensors */ -#define TCS37727_NUM (sizeof(tcs37727_params) / sizeof(tcs37727_params[0])) +#define TCS37727_NUM ARRAY_SIZE(tcs37727_params) /** * @brief Allocate memory for the device descriptors @@ -45,7 +45,7 @@ static saul_reg_t saul_entries[TCS37727_NUM]; /** * @brief Define the number of saul info */ -#define TCS37727_INFO_NUM (sizeof(tcs37727_saul_info) / sizeof(tcs37727_saul_info[0])) +#define TCS37727_INFO_NUM ARRAY_SIZE(tcs37727_saul_info) /** * @brief Export the sensor's SAUL interface diff --git a/sys/auto_init/saul/auto_init_tmp006.c b/sys/auto_init/saul/auto_init_tmp006.c index 77fbdd5e6b..61261e8252 100644 --- a/sys/auto_init/saul/auto_init_tmp006.c +++ b/sys/auto_init/saul/auto_init_tmp006.c @@ -31,7 +31,7 @@ /** * @brief Define the number of configured sensors */ -#define TMP006_NUM (sizeof(tmp006_params) / sizeof(tmp006_params[0])) +#define TMP006_NUM ARRAY_SIZE(tmp006_params) /** * @brief Allocate memory for the device descriptors @@ -46,7 +46,7 @@ static saul_reg_t saul_entries[TMP006_NUM]; /** * @brief Define the number of saul info */ -#define TMP006_INFO_NUM (sizeof(tmp006_saul_info) / sizeof(tmp006_saul_info[0])) +#define TMP006_INFO_NUM ARRAY_SIZE(tmp006_saul_info) /** * @brief Reference the driver struct diff --git a/sys/auto_init/saul/auto_init_tsl2561.c b/sys/auto_init/saul/auto_init_tsl2561.c index ee15bf9c8d..311d2a0670 100644 --- a/sys/auto_init/saul/auto_init_tsl2561.c +++ b/sys/auto_init/saul/auto_init_tsl2561.c @@ -29,7 +29,7 @@ /** * @brief Define the number of configured sensors */ -#define TSL2561_NUMOF (sizeof(tsl2561_params) / sizeof(tsl2561_params[0])) +#define TSL2561_NUMOF ARRAY_SIZE(tsl2561_params) /** * @brief Allocation of memory for device descriptors @@ -44,7 +44,7 @@ static saul_reg_t saul_entries[TSL2561_NUMOF]; /** * @brief Define the number of saul info */ -#define TSL2561_INFO_NUMOF (sizeof(tsl2561_saul_info) / sizeof(tsl2561_saul_info[0])) +#define TSL2561_INFO_NUMOF ARRAY_SIZE(tsl2561_saul_info) /** * @brief Reference the driver structs. diff --git a/sys/auto_init/saul/auto_init_tsl4531x.c b/sys/auto_init/saul/auto_init_tsl4531x.c index 0496666df1..0646d99752 100644 --- a/sys/auto_init/saul/auto_init_tsl4531x.c +++ b/sys/auto_init/saul/auto_init_tsl4531x.c @@ -32,7 +32,7 @@ /** * @brief Define the number of configured sensors */ -#define TSL4531X_NUMOF (sizeof(tsl4531x_params) / sizeof(tsl4531x_params[0])) +#define TSL4531X_NUMOF ARRAY_SIZE(tsl4531x_params) /** * @brief Allocation of memory for device descriptors @@ -48,7 +48,7 @@ static saul_reg_t saul_entries[TSL4531X_NUMOF]; /** * @brief Define the number of saul info */ -#define TSL4531X_INFO_NUMOF (sizeof(tsl4531x_saul_info) / sizeof(tsl4531x_saul_info[0])) +#define TSL4531X_INFO_NUMOF ARRAY_SIZE(tsl4531x_saul_info) /** * @brief Reference the driver structs. diff --git a/sys/auto_init/saul/auto_init_vcnl40x0.c b/sys/auto_init/saul/auto_init_vcnl40x0.c index b8d1e3feda..c0a1254620 100644 --- a/sys/auto_init/saul/auto_init_vcnl40x0.c +++ b/sys/auto_init/saul/auto_init_vcnl40x0.c @@ -30,7 +30,7 @@ /** * @brief Define the number of configured sensors */ -#define VCNL40X0_NUMOF (sizeof(vcnl40x0_params) / sizeof(vcnl40x0_params[0])) +#define VCNL40X0_NUMOF ARRAY_SIZE(vcnl40x0_params) /** * @brief Allocation of memory for device descriptors diff --git a/sys/auto_init/saul/auto_init_veml6070.c b/sys/auto_init/saul/auto_init_veml6070.c index 72559e94f2..6e8fc38962 100644 --- a/sys/auto_init/saul/auto_init_veml6070.c +++ b/sys/auto_init/saul/auto_init_veml6070.c @@ -29,7 +29,7 @@ /** * @brief Define the number of configured sensors */ -#define VEML6070_NUM (sizeof(veml6070_params) / sizeof(veml6070_params[0])) +#define VEML6070_NUM ARRAY_SIZE(veml6070_params) /** * @brief Allocation of memory for device descriptors @@ -44,7 +44,7 @@ static saul_reg_t saul_entries[VEML6070_NUM]; /** * @brief Define the number of saul info */ -#define VEML6070_INFO_NUM (sizeof(veml6070_saul_info) / sizeof(veml6070_saul_info[0])) +#define VEML6070_INFO_NUM ARRAY_SIZE(veml6070_saul_info) /** * @brief Reference the driver structs. diff --git a/sys/auto_init/storage/auto_init_sdcard_spi.c b/sys/auto_init/storage/auto_init_sdcard_spi.c index 1e57be14e7..d18e3b3240 100644 --- a/sys/auto_init/storage/auto_init_sdcard_spi.c +++ b/sys/auto_init/storage/auto_init_sdcard_spi.c @@ -29,7 +29,7 @@ * @brief number of used sd cards * @{ */ -#define SDCARD_SPI_NUM (sizeof(sdcard_spi_params) / sizeof(sdcard_spi_params[0])) +#define SDCARD_SPI_NUM ARRAY_SIZE(sdcard_spi_params) /** @} */ /** diff --git a/sys/fmt/fmt.c b/sys/fmt/fmt.c index 1e70126931..d0d96b354f 100644 --- a/sys/fmt/fmt.c +++ b/sys/fmt/fmt.c @@ -46,7 +46,7 @@ static const uint32_t _tenmap[] = { 10000000LU, }; -#define TENMAP_SIZE (sizeof(_tenmap) / sizeof(_tenmap[0])) +#define TENMAP_SIZE ARRAY_SIZE(_tenmap) static inline int _is_digit(char c) { diff --git a/sys/include/embUnit.h b/sys/include/embUnit.h index f8d4045d26..32ec3331ad 100644 --- a/sys/include/embUnit.h +++ b/sys/include/embUnit.h @@ -22,6 +22,7 @@ #define EMBUNIT_H #include "embUnit/embUnit.h" +#include "kernel_defines.h" #ifdef OUTPUT # define OUTPUT_XML (1) diff --git a/sys/include/phydat.h b/sys/include/phydat.h index d56f968ed1..ff5569af58 100644 --- a/sys/include/phydat.h +++ b/sys/include/phydat.h @@ -36,6 +36,7 @@ #define PHYDAT_H #include +#include "kernel_defines.h" #ifdef __cplusplus extern "C" { diff --git a/sys/net/application_layer/gcoap/gcoap.c b/sys/net/application_layer/gcoap/gcoap.c index 04d4bae326..bce460ea7c 100644 --- a/sys/net/application_layer/gcoap/gcoap.c +++ b/sys/net/application_layer/gcoap/gcoap.c @@ -62,7 +62,7 @@ const coap_resource_t _default_resources[] = { static gcoap_listener_t _default_listener = { &_default_resources[0], - sizeof(_default_resources) / sizeof(_default_resources[0]), + ARRAY_SIZE(_default_resources), NULL, NULL }; diff --git a/sys/net/gnrc/application_layer/tftp/gnrc_tftp.c b/sys/net/gnrc/application_layer/tftp/gnrc_tftp.c index 474cdff710..e787ba84e3 100644 --- a/sys/net/gnrc/application_layer/tftp/gnrc_tftp.c +++ b/sys/net/gnrc/application_layer/tftp/gnrc_tftp.c @@ -53,7 +53,6 @@ static kernel_pid_t _tftp_kernel_pid; #endif #define MIN(a, b) ((a) > (b) ? (b) : (a)) -#define ARRAY_LEN(x) (sizeof(x) / sizeof(x[0])) #define TFTP_TIMEOUT_MSG 0x4000 #define TFTP_STOP_SERVER_MSG 0x4001 @@ -1079,7 +1078,7 @@ int _tftp_decode_start(tftp_context_t *ctxt, gnrc_pktsnip_t *inpkt, gnrc_pktsnip DEBUG("tftp: incoming request '%s', mode: %s\n", ctxt->file_name, str_mode); /* decode the TFTP transfer mode */ - for (uint32_t idx = 0; idx < ARRAY_LEN(_tftp_modes); ++idx) { + for (uint32_t idx = 0; idx < ARRAY_SIZE(_tftp_modes); ++idx) { if (_tftp_modes[idx].len > (inpkt->size - sizeof(*hdr) - fnlen)) { continue; } @@ -1110,7 +1109,7 @@ int _tftp_decode_options(tftp_context_t *ctxt, gnrc_pktsnip_t *buf, uint32_t sta offset += strlen(value) + 1; /* check what option we are parsing */ - for (uint32_t idx = 0; idx < ARRAY_LEN(_tftp_options); ++idx) { + for (uint32_t idx = 0; idx < ARRAY_SIZE(_tftp_options); ++idx) { if (memcmp(name, _tftp_options[idx].name, _tftp_options[idx].len) == 0) { /* set the option value of the known options */ switch (idx) { diff --git a/sys/net/gnrc/application_layer/uhcpc/gnrc_uhcpc.c b/sys/net/gnrc/application_layer/uhcpc/gnrc_uhcpc.c index 5b9a085cf6..7299bf22cf 100644 --- a/sys/net/gnrc/application_layer/uhcpc/gnrc_uhcpc.c +++ b/sys/net/gnrc/application_layer/uhcpc/gnrc_uhcpc.c @@ -129,7 +129,7 @@ static void* uhcp_client_thread(void *arg) { (void)arg; - msg_init_queue(_uhcp_msg_queue, sizeof(_uhcp_msg_queue)/sizeof(msg_t)); + msg_init_queue(_uhcp_msg_queue, ARRAY_SIZE(_uhcp_msg_queue)); uhcp_client(gnrc_border_interface); return NULL; } diff --git a/sys/net/routing/nhdp/nhdp_reader.c b/sys/net/routing/nhdp/nhdp_reader.c index f29d6e2f32..f74bf3e43d 100644 --- a/sys/net/routing/nhdp/nhdp_reader.c +++ b/sys/net/routing/nhdp/nhdp_reader.c @@ -108,9 +108,9 @@ void nhdp_reader_init(void) /* Register HELLO message consumer */ rfc5444_reader_add_message_consumer(&reader, &_nhdp_msg_consumer, - _nhdp_msg_tlvs, ARRAYSIZE(_nhdp_msg_tlvs)); + _nhdp_msg_tlvs, ARRAY_SIZE(_nhdp_msg_tlvs)); rfc5444_reader_add_message_consumer(&reader, &_nhdp_address_consumer, - _nhdp_addr_tlvs, ARRAYSIZE(_nhdp_addr_tlvs)); + _nhdp_addr_tlvs, ARRAY_SIZE(_nhdp_addr_tlvs)); } int nhdp_reader_handle_packet(kernel_pid_t rcvg_if_pid, void *buffer, size_t length) diff --git a/sys/net/routing/nhdp/nhdp_writer.c b/sys/net/routing/nhdp/nhdp_writer.c index 8caa80dddf..22be9d1497 100644 --- a/sys/net/routing/nhdp/nhdp_writer.c +++ b/sys/net/routing/nhdp/nhdp_writer.c @@ -90,7 +90,7 @@ void nhdp_writer_init(void) /* Register HELLO msg with 16 byte addresses and content provider */ rfc5444_writer_register_msgcontentprovider(&nhdp_writer, - &_nhdp_message_content_provider, _nhdp_addrtlvs, ARRAYSIZE(_nhdp_addrtlvs)); + &_nhdp_message_content_provider, _nhdp_addrtlvs, ARRAY_SIZE(_nhdp_addrtlvs)); _hello_msg = rfc5444_writer_register_message(&nhdp_writer, RFC5444_MSGTYPE_HELLO, false, 16); _hello_msg->addMessageHeader = _nhdp_add_hello_msg_header_cb; diff --git a/sys/phydat/phydat.c b/sys/phydat/phydat.c index 7c8dd82df0..8fb96974c3 100644 --- a/sys/phydat/phydat.c +++ b/sys/phydat/phydat.c @@ -56,11 +56,11 @@ static const uint32_t divisors[] = { 10, }; -#define LOOKUP_LEN (sizeof(lookup_table_positive) / sizeof(int32_t)) +#define LOOKUP_LEN ARRAY_SIZE(lookup_table_positive) void phydat_fit(phydat_t *dat, const int32_t *values, unsigned int dim) { - assert(dim <= (sizeof(dat->val) / sizeof(dat->val[0]))); + assert(dim <= ARRAY_SIZE(dat->val)); uint32_t divisor = 0; uint32_t max = 0; const uint32_t *lookup = lookup_table_positive; diff --git a/sys/riotboot/slot.c b/sys/riotboot/slot.c index 0a0df2c78d..fa4b79738c 100644 --- a/sys/riotboot/slot.c +++ b/sys/riotboot/slot.c @@ -40,7 +40,7 @@ const riotboot_hdr_t * const riotboot_slots[] = { }; /* Calculate the number of slots */ -const unsigned riotboot_slot_numof = sizeof(riotboot_slots) / sizeof(riotboot_hdr_t*); +const unsigned riotboot_slot_numof = ARRAY_SIZE(riotboot_slots); static void _riotboot_slot_jump_to_image(const riotboot_hdr_t *hdr) { diff --git a/sys/shell/commands/sc_gnrc_netif.c b/sys/shell/commands/sc_gnrc_netif.c index b6404c656a..dda9df911d 100644 --- a/sys/shell/commands/sc_gnrc_netif.c +++ b/sys/shell/commands/sc_gnrc_netif.c @@ -44,11 +44,6 @@ */ #define _LINE_THRESHOLD (8U) -/** - * @brief Determine length of array in elements - */ -#define _ARRAY_LEN(x) (sizeof(x) / sizeof(x[0])) - /** * @brief Flag command mapping * @@ -177,9 +172,9 @@ static void _set_usage(char *cmd_name) static void _flag_usage(char *cmd_name) { printf("usage: %s [-]{", cmd_name); - for (unsigned i = 0; i < _ARRAY_LEN(flag_cmds); i++) { + for (unsigned i = 0; i < ARRAY_SIZE(flag_cmds); i++) { printf("%s", flag_cmds[i].name); - if (i < (_ARRAY_LEN(flag_cmds) - 1)) { + if (i < (ARRAY_SIZE(flag_cmds) - 1)) { printf("|"); } } @@ -1073,7 +1068,7 @@ static int _netif_flag(char *cmd, kernel_pid_t iface, char *flag) set = NETOPT_DISABLE; flag++; } - for (unsigned i = 0; i < _ARRAY_LEN(flag_cmds); i++) { + for (unsigned i = 0; i < ARRAY_SIZE(flag_cmds); i++) { if (strcmp(flag_cmds[i].name, flag) == 0) { return _netif_set_flag(iface, flag_cmds[i].opt, set); } diff --git a/sys/shell/commands/sc_sht1x.c b/sys/shell/commands/sc_sht1x.c index a0aa8e816f..1cd1627c97 100644 --- a/sys/shell/commands/sc_sht1x.c +++ b/sys/shell/commands/sc_sht1x.c @@ -27,7 +27,7 @@ #include "sht1x.h" #include "sht1x_params.h" -#define SHT1X_NUM (sizeof(sht1x_params) / sizeof(sht1x_params[0])) +#define SHT1X_NUM ARRAY_SIZE(sht1x_params) extern sht1x_dev_t sht1x_devs[SHT1X_NUM]; diff --git a/sys/shell/shell.c b/sys/shell/shell.c index 880d320b0f..5f723c22aa 100644 --- a/sys/shell/shell.c +++ b/sys/shell/shell.c @@ -63,7 +63,7 @@ static shell_command_handler_t find_handler(const shell_command_t *command_list, const shell_command_t *entry; /* iterating over command_lists */ - for (unsigned int i = 0; i < sizeof(command_lists) / sizeof(entry); i++) { + for (unsigned int i = 0; i < ARRAY_SIZE(command_lists); i++) { if ((entry = command_lists[i])) { /* iterating over commands in command_lists entry */ while (entry->name != NULL) { @@ -95,7 +95,7 @@ static void print_help(const shell_command_t *command_list) const shell_command_t *entry; /* iterating over command_lists */ - for (unsigned int i = 0; i < sizeof(command_lists) / sizeof(entry); i++) { + for (unsigned int i = 0; i < ARRAY_SIZE(command_lists); i++) { if ((entry = command_lists[i])) { /* iterating over commands in command_lists entry */ while (entry->name != NULL) {