1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

sys: make use of ARRAY_SIZE macro

This commit is contained in:
Benjamin Valentin 2019-07-18 15:16:43 +02:00
parent 4918dfe590
commit e8dc1119b8
72 changed files with 116 additions and 119 deletions

View File

@ -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)
{

View File

@ -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)

View File

@ -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)

View File

@ -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];

View File

@ -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];

View File

@ -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

View File

@ -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

View File

@ -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];

View File

@ -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];

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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)
/**

View File

@ -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

View File

@ -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

View File

@ -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
*/

View File

@ -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]);

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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)
/**

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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.

View File

@ -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

View File

@ -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.

View File

@ -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)
/** @} */
/**

View File

@ -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)
{

View File

@ -22,6 +22,7 @@
#define EMBUNIT_H
#include "embUnit/embUnit.h"
#include "kernel_defines.h"
#ifdef OUTPUT
# define OUTPUT_XML (1)

View File

@ -36,6 +36,7 @@
#define PHYDAT_H
#include <stdint.h>
#include "kernel_defines.h"
#ifdef __cplusplus
extern "C" {

View File

@ -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
};

View File

@ -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) {

View File

@ -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;
}

View File

@ -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)

View File

@ -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;

View File

@ -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;

View File

@ -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)
{

View File

@ -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 <if_id> [-]{", 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);
}

View File

@ -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];

View File

@ -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) {