mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 04:52:59 +01:00
tests: make use of ARRAY_SIZE macro
This commit is contained in:
parent
8af04cd939
commit
4918dfe590
@ -617,10 +617,10 @@ static void estimate_cpu_overhead(void)
|
||||
int main(void)
|
||||
{
|
||||
print_str("\nStatistical benchmark for timers\n");
|
||||
for (unsigned int k = 0; k < (sizeof(ref_states) / sizeof(ref_states[0])); ++k) {
|
||||
for (unsigned int k = 0; k < ARRAY_SIZE(ref_states); ++k) {
|
||||
matstat_clear(&ref_states[k]);
|
||||
}
|
||||
for (unsigned int k = 0; k < (sizeof(int_states) / sizeof(int_states[0])); ++k) {
|
||||
for (unsigned int k = 0; k < ARRAY_SIZE(int_states); ++k) {
|
||||
matstat_clear(&int_states[k]);
|
||||
}
|
||||
/* print test overview */
|
||||
@ -661,7 +661,7 @@ int main(void)
|
||||
print_u32_dec(log2test);
|
||||
print("\n", 1);
|
||||
print_str("state vector elements per variant = ");
|
||||
print_u32_dec(sizeof(ref_states) / sizeof(ref_states[0]) / TEST_VARIANT_NUMOF);
|
||||
print_u32_dec(ARRAY_SIZE(ref_states) / TEST_VARIANT_NUMOF);
|
||||
print("\n", 1);
|
||||
print_str("number of variants = ");
|
||||
print_u32_dec(TEST_VARIANT_NUMOF);
|
||||
|
@ -47,7 +47,7 @@ static int help(int argc, char **argv)
|
||||
puts("Help:");
|
||||
puts("\tinit [trx_id] - initialize a trx");
|
||||
puts("\tset_mode [trx_id] [mode] - set a mode on the trx");
|
||||
printf("trx_id: 0..%u\n", (unsigned)(sizeof(devs) / sizeof(devs[0])));
|
||||
printf("trx_id: 0..%u\n", (unsigned)ARRAY_SIZE(devs));
|
||||
puts("modes:");
|
||||
puts("\t0: normal mode");
|
||||
puts("\t1: silent mode");
|
||||
@ -67,7 +67,7 @@ static int init(int argc, char **argv) {
|
||||
}
|
||||
|
||||
unsigned trx = atoi(argv[1]);
|
||||
if (trx < (sizeof(devs) / sizeof(devs[0]))) {
|
||||
if (trx < ARRAY_SIZE(devs)) {
|
||||
int res = can_trx_init(devs[trx]);
|
||||
if (res >= 0) {
|
||||
puts("Trx successfully initialized");
|
||||
@ -93,7 +93,7 @@ static int set_mode(int argc, char **argv) {
|
||||
}
|
||||
unsigned trx = atoi(argv[1]);
|
||||
unsigned mode = atoi(argv[2]);
|
||||
if ((trx < (sizeof(devs) / sizeof(devs[0]))) &&
|
||||
if ((trx < ARRAY_SIZE(devs)) &&
|
||||
(mode <= TRX_HIGH_VOLTAGE_WAKE_UP_MODE)) {
|
||||
int res = can_trx_set_mode(devs[trx], mode);
|
||||
if (res >= 0) {
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "at86rf2xx.h"
|
||||
#include "at86rf2xx_params.h"
|
||||
#include "net/netdev.h"
|
||||
#include "kernel_defines.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -33,7 +34,7 @@ extern "C" {
|
||||
* @internal
|
||||
* @{
|
||||
*/
|
||||
#define AT86RF2XX_NUM (sizeof(at86rf2xx_params) / sizeof(at86rf2xx_params[0]))
|
||||
#define AT86RF2XX_NUM ARRAY_SIZE(at86rf2xx_params)
|
||||
|
||||
extern at86rf2xx_t devs[AT86RF2XX_NUM];
|
||||
|
||||
|
@ -23,12 +23,13 @@
|
||||
#include "board.h"
|
||||
#include "ds3234.h"
|
||||
#include "ds3234_params.h"
|
||||
#include "kernel_defines.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
puts("DS3234 RTC PPS test application\n");
|
||||
|
||||
for (unsigned k = 0; k < (sizeof(ds3234_params) / sizeof(ds3234_params[0])); ++k) {
|
||||
for (unsigned k = 0; k < ARRAY_SIZE(ds3234_params); ++k) {
|
||||
printf("Init #%u... ", k);
|
||||
int res = ds3234_pps_init(&ds3234_params[k]);
|
||||
if (res == 0) {
|
||||
|
@ -16,8 +16,6 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define ARRAY_LEN(array) (sizeof(array)/sizeof(array[0]))
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
int addr;
|
||||
@ -112,7 +110,7 @@ static int32_t parse_baud(char *arg)
|
||||
{
|
||||
int32_t baud = atoi(arg);
|
||||
|
||||
for (size_t i = 0 ; i < ARRAY_LEN(baudrates) ; i++) {
|
||||
for (size_t i = 0 ; i < ARRAY_SIZE(baudrates); i++) {
|
||||
if (baud == baudrates[i]) {
|
||||
return baud;
|
||||
}
|
||||
@ -137,14 +135,14 @@ static void parse_reg(char *arg, int *reg8, int *reg16)
|
||||
*reg8 = -1;
|
||||
*reg16 = -1;
|
||||
|
||||
for (size_t i = 0 ; i < ARRAY_LEN(regs8) ; i++) {
|
||||
for (size_t i = 0 ; i < ARRAY_SIZE(regs8); i++) {
|
||||
if (strcmp(arg, regs8[i].name) == 0) {
|
||||
*reg8 = regs8[i].addr;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0 ; i < ARRAY_LEN(regs16) ; i++) {
|
||||
for (size_t i = 0 ; i < ARRAY_SIZE(regs16); i++) {
|
||||
if (strcmp(arg, regs16[i].name) == 0) {
|
||||
*reg16 = regs16[i].addr;
|
||||
return;
|
||||
@ -157,12 +155,12 @@ static void parse_reg(char *arg, int *reg8, int *reg16)
|
||||
void print_registers(void)
|
||||
{
|
||||
puts("available 8bits registers :");
|
||||
for (size_t i = 0 ; i < ARRAY_LEN(regs8) ; i++) {
|
||||
for (size_t i = 0 ; i < ARRAY_SIZE(regs8); i++) {
|
||||
printf("\t%s\n", regs8[i].name);
|
||||
}
|
||||
|
||||
puts("available 16bits registers :");
|
||||
for (size_t i = 0 ; i < ARRAY_LEN(regs16) ; i++) {
|
||||
for (size_t i = 0 ; i < ARRAY_SIZE(regs16); i++) {
|
||||
printf("\t%s\n", regs16[i].name);
|
||||
}
|
||||
}
|
||||
@ -176,7 +174,7 @@ static int cmd_init(int argc, char **argv)
|
||||
if (argc != 3 && argc != 4) {
|
||||
printf("usage; %s <uart> <baudrate> [<timeout_us>]\n", argv[0]);
|
||||
puts("available baudrates :");
|
||||
for (size_t i = 0 ; i < ARRAY_LEN(baudrates) ; i++) {
|
||||
for (size_t i = 0 ; i < ARRAY_SIZE(baudrates); i++) {
|
||||
printf("\t%ld\n", (long int)baudrates[i]);
|
||||
}
|
||||
return 1;
|
||||
@ -207,7 +205,8 @@ static int cmd_init(int argc, char **argv)
|
||||
.dir = { dir_init, dir_enable_tx, dir_disable_tx },
|
||||
};
|
||||
|
||||
int ret = uart_half_duplex_init(&stream, dynamixel_buffer, ARRAY_LEN(dynamixel_buffer), ¶ms);
|
||||
int ret = uart_half_duplex_init(&stream, dynamixel_buffer,
|
||||
ARRAY_SIZE(dynamixel_buffer), ¶ms);
|
||||
|
||||
if (argc == 4) {
|
||||
stream.timeout_us = timeout;
|
||||
|
@ -14,8 +14,6 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define ARRAY_LEN(array) (sizeof(array)/sizeof(array[0]))
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
int addr;
|
||||
@ -97,7 +95,7 @@ static int32_t parse_baud(char *arg)
|
||||
{
|
||||
int32_t baud = atoi(arg);
|
||||
|
||||
for (size_t i = 0 ; i < ARRAY_LEN(baudrates) ; i++) {
|
||||
for (size_t i = 0 ; i < ARRAY_SIZE(baudrates); i++) {
|
||||
if (baud == baudrates[i]) {
|
||||
return baud;
|
||||
}
|
||||
@ -122,14 +120,14 @@ static void parse_reg(char *arg, int *reg8, int *reg16)
|
||||
*reg8 = -1;
|
||||
*reg16 = -1;
|
||||
|
||||
for (size_t i = 0 ; i < ARRAY_LEN(regs8) ; i++) {
|
||||
for (size_t i = 0 ; i < ARRAY_SIZE(regs8); i++) {
|
||||
if (strcmp(arg, regs8[i].name) == 0) {
|
||||
*reg8 = regs8[i].addr;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0 ; i < ARRAY_LEN(regs16) ; i++) {
|
||||
for (size_t i = 0 ; i < ARRAY_SIZE(regs16); i++) {
|
||||
if (strcmp(arg, regs16[i].name) == 0) {
|
||||
*reg16 = regs16[i].addr;
|
||||
return;
|
||||
@ -141,12 +139,12 @@ static void parse_reg(char *arg, int *reg8, int *reg16)
|
||||
|
||||
void print_registers(void) {
|
||||
puts("available 8bits registers :");
|
||||
for (size_t i = 0 ; i < ARRAY_LEN(regs8) ; i++) {
|
||||
for (size_t i = 0 ; i < ARRAY_SIZE(regs8); i++) {
|
||||
printf("\t%s\n", regs8[i].name);
|
||||
}
|
||||
|
||||
puts("available 16bits registers :");
|
||||
for (size_t i = 0 ; i < ARRAY_LEN(regs16) ; i++) {
|
||||
for (size_t i = 0 ; i < ARRAY_SIZE(regs16); i++) {
|
||||
printf("\t%s\n", regs16[i].name);
|
||||
}
|
||||
}
|
||||
@ -159,7 +157,7 @@ static int cmd_init(int argc, char **argv) {
|
||||
if (argc != 3 && argc != 4) {
|
||||
printf("usage; %s <uart> <baudrate> [<timeout_us>]\n", argv[0]);
|
||||
puts("available baudrates :");
|
||||
for (size_t i = 0 ; i < ARRAY_LEN(baudrates) ; i++) {
|
||||
for (size_t i = 0 ; i < ARRAY_SIZE(baudrates); i++) {
|
||||
printf("\t%ld\n", (long int)baudrates[i]);
|
||||
}
|
||||
return 1;
|
||||
@ -190,7 +188,7 @@ static int cmd_init(int argc, char **argv) {
|
||||
.dir = UART_HALF_DUPLEX_DIR_NONE,
|
||||
};
|
||||
|
||||
int ret = uart_half_duplex_init(&stream, feetech_buffer, ARRAY_LEN(feetech_buffer), ¶ms);
|
||||
int ret = uart_half_duplex_init(&stream, feetech_buffer, ARRAY_SIZE(feetech_buffer), ¶ms);
|
||||
|
||||
if (argc == 4) {
|
||||
stream.timeout_us = timeout;
|
||||
|
@ -76,7 +76,7 @@ int main(void)
|
||||
"ISL29125_MODE_R", "ISL29125_MODE_G", "ISL29125_MODE_B",
|
||||
"ISL29125_MODE_RG", "ISL29125_MODE_GB"};
|
||||
|
||||
for (size_t i = 0; i < sizeof(modes) / sizeof(modes[0]); i++) {
|
||||
for (size_t i = 0; i < ARRAY_SIZE(modes); i++) {
|
||||
printf("Setting mode %s\n", mode_names[i]);
|
||||
isl29125_set_mode(&dev, modes[i]);
|
||||
xtimer_usleep(SLEEP);
|
||||
|
@ -36,7 +36,7 @@
|
||||
|
||||
/* this is provided by the sdcard_spi driver
|
||||
* see sys/auto_init/storage/auto_init_sdcard_spi.c */
|
||||
extern sdcard_spi_t sdcard_spi_devs[sizeof(sdcard_spi_params) / sizeof(sdcard_spi_params[0])];
|
||||
extern sdcard_spi_t sdcard_spi_devs[ARRAY_SIZE(sdcard_spi_params)];
|
||||
sdcard_spi_t *card = &sdcard_spi_devs[0];
|
||||
|
||||
uint8_t buffer[SD_HC_BLOCK_SIZE * MAX_BLOCKS_IN_BUFFER];
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "shell_commands.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];
|
||||
static sht1x_dev_t *dev = &sht1x_devs[0];
|
||||
|
||||
|
@ -40,7 +40,7 @@ static evtimer_msg_event_t events[] = {
|
||||
{ .event = { .offset = 0 }, .msg = { .content = { .ptr = "8" } } },
|
||||
};
|
||||
|
||||
#define NEVENTS (sizeof(events) / sizeof(evtimer_msg_event_t))
|
||||
#define NEVENTS ARRAY_SIZE(events)
|
||||
|
||||
/* This thread will print the drift to stdout once per second */
|
||||
void *worker_thread(void *arg)
|
||||
|
@ -65,7 +65,7 @@ static void binary_ops(void)
|
||||
}
|
||||
|
||||
|
||||
for (unsigned o = 0; o < sizeof(ops) / sizeof(*ops); ++o) {
|
||||
for (unsigned o = 0; o < ARRAY_SIZE(ops); ++o) {
|
||||
fix16_t c = ops[o].fun(a, b);
|
||||
|
||||
char buf[3][14];
|
||||
@ -96,7 +96,7 @@ static void unary_ops(void)
|
||||
};
|
||||
|
||||
for (fix16_t input = fix16_from_dbl(-10.0); input < fix16_from_dbl(+10.0); input += fix16_from_dbl(0.25)) {
|
||||
for (unsigned o = 0; o < sizeof(ops) / sizeof(*ops); ++o) {
|
||||
for (unsigned o = 0; o < ARRAY_SIZE(ops); ++o) {
|
||||
fix16_t result = ops[o].fun(input);
|
||||
|
||||
char buf[2][14];
|
||||
@ -121,7 +121,7 @@ static void unary_ops(void)
|
||||
};
|
||||
|
||||
for (fix16_t input = fix16_from_dbl(-M_PI/2); input < fix16_from_dbl(+M_PI/2); input += fix16_from_dbl(0.05)) {
|
||||
for (unsigned o = 0; o < sizeof(ops) / sizeof(*ops); ++o) {
|
||||
for (unsigned o = 0; o < ARRAY_SIZE(ops); ++o) {
|
||||
fix16_t result = ops[o].fun(input);
|
||||
|
||||
char buf[2][14];
|
||||
@ -144,7 +144,7 @@ static void unary_ops(void)
|
||||
};
|
||||
|
||||
for (fix16_t input = fix16_from_dbl(-1.0); input < fix16_from_dbl(+1.0); input += fix16_from_dbl(0.05)) {
|
||||
for (unsigned o = 0; o < sizeof(ops) / sizeof(*ops); ++o) {
|
||||
for (unsigned o = 0; o < ARRAY_SIZE(ops); ++o) {
|
||||
fix16_t result = ops[o].fun(input);
|
||||
|
||||
char buf[2][14];
|
||||
@ -170,7 +170,7 @@ static void unary_ops(void)
|
||||
};
|
||||
|
||||
for (fix16_t input = fix16_from_dbl(0.05); input < fix16_from_dbl(+10.0); input += fix16_from_dbl(0.25)) {
|
||||
for (unsigned o = 0; o < sizeof(ops) / sizeof(*ops); ++o) {
|
||||
for (unsigned o = 0; o < ARRAY_SIZE(ops); ++o) {
|
||||
fix16_t result = ops[o].fun(input);
|
||||
|
||||
char buf[2][14];
|
||||
|
@ -64,9 +64,9 @@ const struct lua_riot_builtin_lua *const lua_riot_builtin_lua_table = _lua_riot_
|
||||
const struct lua_riot_builtin_c *const lua_riot_builtin_c_table = _lua_riot_builtin_c_table;
|
||||
|
||||
const size_t lua_riot_builtin_lua_table_len =
|
||||
sizeof(_lua_riot_builtin_lua_table) / sizeof(*_lua_riot_builtin_lua_table);
|
||||
ARRAY_SIZE(_lua_riot_builtin_lua_table);
|
||||
const size_t lua_riot_builtin_c_table_len =
|
||||
sizeof(_lua_riot_builtin_c_table) / sizeof(*_lua_riot_builtin_c_table);
|
||||
ARRAY_SIZE(_lua_riot_builtin_c_table);
|
||||
|
||||
#define LUA_MEM_SIZE (11000)
|
||||
static char lua_mem[LUA_MEM_SIZE] __attribute__ ((aligned(__BIGGEST_ALIGNMENT__)));
|
||||
|
@ -92,7 +92,7 @@ int nanotest_client_cmd(int argc, char **argv)
|
||||
}
|
||||
|
||||
int code_pos = -1;
|
||||
for (size_t i = 0; i < sizeof(method_codes) / sizeof(char*); i++) {
|
||||
for (size_t i = 0; i < ARRAY_SIZE(method_codes); i++) {
|
||||
if (strcmp(argv[1], method_codes[i]) == 0) {
|
||||
code_pos = i;
|
||||
}
|
||||
|
@ -77,4 +77,4 @@ const coap_resource_t coap_resources[] = {
|
||||
{ "/value", COAP_GET | COAP_PUT | COAP_POST, _value_handler, NULL },
|
||||
};
|
||||
|
||||
const unsigned coap_resources_numof = sizeof(coap_resources) / sizeof(coap_resources[0]);
|
||||
const unsigned coap_resources_numof = ARRAY_SIZE(coap_resources);
|
||||
|
@ -56,10 +56,10 @@ static char printer_stack[THREAD_STACKSIZE_MAIN];
|
||||
#ifdef MODULE_PERIPH_UART_MODECFG
|
||||
static uart_data_bits_t data_bits_lut[] = { UART_DATA_BITS_5, UART_DATA_BITS_6,
|
||||
UART_DATA_BITS_7, UART_DATA_BITS_8 };
|
||||
static int data_bits_lut_len = sizeof(data_bits_lut)/sizeof(data_bits_lut[0]);
|
||||
static int data_bits_lut_len = ARRAY_SIZE(data_bits_lut);
|
||||
|
||||
static uart_stop_bits_t stop_bits_lut[] = { UART_STOP_BITS_1, UART_STOP_BITS_2 };
|
||||
static int stop_bits_lut_len = sizeof(stop_bits_lut)/sizeof(stop_bits_lut[0]);
|
||||
static int stop_bits_lut_len = ARRAY_SIZE(stop_bits_lut);
|
||||
#endif
|
||||
|
||||
static int parse_dev(char *arg)
|
||||
|
@ -134,7 +134,7 @@ static void test_parse(void)
|
||||
"bf61610161629f0203ffff", // {_ "a": 1, "b": [_ 2, 3]}
|
||||
};
|
||||
|
||||
for (test = 0; test < sizeof(tests) / sizeof(char*); test++) {
|
||||
for (test = 0; test < ARRAY_SIZE(tests); test++) {
|
||||
unsigned char buf[64] = {0};
|
||||
TEST_ASSERT((strlen(tests[test])/2) <= sizeof(buf));
|
||||
|
||||
@ -172,7 +172,7 @@ static void test_errors(void)
|
||||
TEST_ASSERT_EQUAL_INT(-1, cn_cbor_encoder_write(ebuf, 0, sizeof(ebuf),
|
||||
&inv));
|
||||
|
||||
for (offs = 0; offs < sizeof(tests) / sizeof(cbor_failure); offs++) {
|
||||
for (offs = 0; offs < ARRAY_SIZE(tests); offs++) {
|
||||
unsigned char buf[32] = {0};
|
||||
TEST_ASSERT((strlen(tests[offs].hex)/2) <= sizeof(buf));
|
||||
|
||||
|
@ -57,14 +57,14 @@ mtd_dev_t *fatfs_mtd_devs[1];
|
||||
#elif MODULE_MTD_SDCARD
|
||||
#include "mtd_sdcard.h"
|
||||
#include "sdcard_spi_params.h"
|
||||
#define SDCARD_SPI_NUM (sizeof(sdcard_spi_params) / sizeof(sdcard_spi_params[0]))
|
||||
#define SDCARD_SPI_NUM ARRAY_SIZE(sdcard_spi_params)
|
||||
/* sdcard devs are provided by sys/auto_init/storage/auto_init_sdcard_spi.c */
|
||||
extern sdcard_spi_t sdcard_spi_devs[SDCARD_SPI_NUM];
|
||||
mtd_sdcard_t mtd_sdcard_devs[SDCARD_SPI_NUM];
|
||||
mtd_dev_t *fatfs_mtd_devs[SDCARD_SPI_NUM];
|
||||
#endif
|
||||
|
||||
#define MTD_NUM (sizeof(fatfs_mtd_devs) / sizeof(fatfs_mtd_devs[0]))
|
||||
#define MTD_NUM ARRAY_SIZE(fatfs_mtd_devs)
|
||||
|
||||
static int _mount(int argc, char **argv)
|
||||
{
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include "vfs.h"
|
||||
#include "mtd.h"
|
||||
|
||||
#include "kernel_defines.h"
|
||||
|
||||
#ifdef MODULE_MTD_SDCARD
|
||||
#include "mtd_sdcard.h"
|
||||
#include "sdcard_spi.h"
|
||||
@ -68,7 +70,7 @@ mtd_dev_t *fatfs_mtd_devs[FF_VOLUMES];
|
||||
/* mtd device for native is provided in boards/native/board_init.c */
|
||||
extern mtd_dev_t *mtd0;
|
||||
#elif MODULE_MTD_SDCARD
|
||||
#define SDCARD_SPI_NUM (sizeof(sdcard_spi_params) / sizeof(sdcard_spi_params[0]))
|
||||
#define SDCARD_SPI_NUM ARRAY_SIZE(sdcard_spi_params)
|
||||
extern sdcard_spi_t sdcard_spi_devs[SDCARD_SPI_NUM];
|
||||
mtd_sdcard_t mtd_sdcard_devs[SDCARD_SPI_NUM];
|
||||
/* always default to first sdcard*/
|
||||
|
@ -31,6 +31,10 @@
|
||||
|
||||
#include "jsmn.h"
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
#define ARRAY_SIZE(a) (sizeof(a)/sizeof(*a))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* A small example of jsmn parsing when JSON structure is known and number of
|
||||
* tokens is predictable.
|
||||
@ -57,7 +61,7 @@ int main(void)
|
||||
jsmntok_t t[16]; /* We expect no more than 16 tokens */
|
||||
|
||||
jsmn_init(&p);
|
||||
r = jsmn_parse(&p, JSON_STRING, strlen(JSON_STRING), t, sizeof(t) / sizeof(t[0]));
|
||||
r = jsmn_parse(&p, JSON_STRING, strlen(JSON_STRING), t, ARRAY_SIZE(t));
|
||||
if (r < 0) {
|
||||
printf("Failed to parse JSON: %d\n", r);
|
||||
return 1;
|
||||
|
@ -71,7 +71,7 @@ const char *tests[] = {
|
||||
static void test_parse(void)
|
||||
{
|
||||
static size_t idx;
|
||||
for (idx = 0; idx < sizeof(tests) / sizeof(char*); idx++) {
|
||||
for (idx = 0; idx < ARRAY_SIZE(tests); idx++) {
|
||||
CborParser parser;
|
||||
CborValue it;
|
||||
unsigned char buf[64] = {0};
|
||||
|
@ -78,4 +78,4 @@ const coap_resource_t coap_resources[] = {
|
||||
{ "/flashwrite", COAP_POST, _flashwrite_handler, &_writer },
|
||||
};
|
||||
|
||||
const unsigned coap_resources_numof = sizeof(coap_resources) / sizeof(coap_resources[0]);
|
||||
const unsigned coap_resources_numof = ARRAY_SIZE(coap_resources);
|
||||
|
@ -44,7 +44,7 @@ static test_values_t test_data[] = {
|
||||
{ 3972L, 9876, 10000L, 0L, ADC_RES_14BIT},
|
||||
};
|
||||
|
||||
#define TEST_DATA_NUMOF (sizeof(test_data) / sizeof(test_data[0]))
|
||||
#define TEST_DATA_NUMOF ARRAY_SIZE(test_data)
|
||||
|
||||
static void test_adc_util_map(void)
|
||||
{
|
||||
|
@ -21,7 +21,7 @@ static priority_queue_node_t qe[Q_LEN];
|
||||
static void set_up(void)
|
||||
{
|
||||
priority_queue_init(&q);
|
||||
for (unsigned i = 0; i < sizeof(qe)/sizeof(priority_queue_node_t); ++i) {
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(qe); ++i) {
|
||||
priority_queue_node_init(&(qe[i]));
|
||||
}
|
||||
}
|
||||
|
@ -65,8 +65,8 @@ static const uint64_t u64_15625_512_expected_values[] = {
|
||||
302231454903657293,
|
||||
};
|
||||
|
||||
#define N_U32_VALS (sizeof(u32_test_values)/sizeof(u32_test_values[0]))
|
||||
#define N_U64_VALS (sizeof(u64_test_values)/sizeof(u64_test_values[0]))
|
||||
#define N_U32_VALS ARRAY_SIZE(u32_test_values)
|
||||
#define N_U64_VALS ARRAY_SIZE(u64_test_values)
|
||||
|
||||
static void test_div_u64_by_15625(void)
|
||||
{
|
||||
|
@ -37,14 +37,14 @@ static const coap_resource_t resources_second[] = {
|
||||
|
||||
static gcoap_listener_t listener = {
|
||||
.resources = &resources[0],
|
||||
.resources_len = (sizeof(resources) / sizeof(resources[0])),
|
||||
.resources_len = ARRAY_SIZE(resources),
|
||||
.link_encoder = NULL,
|
||||
.next = NULL
|
||||
};
|
||||
|
||||
static gcoap_listener_t listener_second = {
|
||||
.resources = &resources_second[0],
|
||||
.resources_len = (sizeof(resources_second) / sizeof(resources_second[0])),
|
||||
.resources_len = ARRAY_SIZE(resources_second),
|
||||
.link_encoder = NULL,
|
||||
.next = NULL
|
||||
};
|
||||
|
@ -212,7 +212,7 @@ static void test_matstat_merge_variance_regr1(void)
|
||||
{ .count = 2414, .sum = 4859, .sum_sq = 1074, .min = 1, .max = 3, .mean = 2 },
|
||||
};
|
||||
matstat_state_t merged = MATSTAT_STATE_INIT;
|
||||
for (unsigned k = 0; k < sizeof(inputs) / sizeof(inputs[0]); ++k) {
|
||||
for (unsigned k = 0; k < ARRAY_SIZE(inputs); ++k) {
|
||||
matstat_merge(&merged, &inputs[k]);
|
||||
}
|
||||
int64_t var = (int64_t)matstat_variance(&merged);
|
||||
|
@ -99,7 +99,7 @@ static void test_phydat_fit(void)
|
||||
{ .val = { -32766, -32766, -32766 }, .unit = UNIT_NONE, .scale = 0 },
|
||||
};
|
||||
|
||||
for (unsigned int i = 0; i < sizeof(dims) / sizeof(dims[0]); i++) {
|
||||
for (unsigned int i = 0; i < ARRAY_SIZE(dims); i++) {
|
||||
phydat_t dat = {
|
||||
.val = { -1, -1, -1 },
|
||||
.scale = scales[i],
|
||||
|
@ -62,11 +62,11 @@ static void test_sht1x_conversion(void)
|
||||
const uint16_t max_raw_hums[] = { 0xff, 0xfff };
|
||||
sht1x_dev_t dev = { .conf = 0 };
|
||||
|
||||
for (size_t i_res = 0; i_res < sizeof(confs) / sizeof(confs[0]); i_res++) {
|
||||
for (size_t i_res = 0; i_res < ARRAY_SIZE(confs); i_res++) {
|
||||
dev.conf = confs[i_res];
|
||||
uint16_t max_raw_temp = max_raw_temps[i_res];
|
||||
uint16_t max_raw_hum = max_raw_hums[i_res];
|
||||
for (size_t i_vdd = 0; i_vdd < sizeof(vdds) / sizeof(vdds[0]); i_vdd++) {
|
||||
for (size_t i_vdd = 0; i_vdd < ARRAY_SIZE(vdds); i_vdd++) {
|
||||
dev.vdd = vdds[i_vdd];
|
||||
for (uint16_t raw_temp = 0; raw_temp <= max_raw_temp; raw_temp++) {
|
||||
int16_t got_temp = sht1x_temperature(&dev, raw_temp);
|
||||
|
@ -52,7 +52,7 @@ static const constfs_file_t _files[] = {
|
||||
|
||||
static const constfs_t fs_data = {
|
||||
.files = _files,
|
||||
.nfiles = sizeof(_files) / sizeof(_files[0]),
|
||||
.nfiles = ARRAY_SIZE(_files),
|
||||
};
|
||||
|
||||
static vfs_mount_t _test_vfs_mount_invalid_mount = {
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "timex.h"
|
||||
|
||||
#define RUNS (5U)
|
||||
#define SLEEP_TIMES_NUMOF (sizeof(sleep_times) / sizeof(sleep_times[0]))
|
||||
#define SLEEP_TIMES_NUMOF ARRAY_SIZE(sleep_times)
|
||||
|
||||
static const uint32_t sleep_times[] = { 10000, 50000, 10234, 56780, 12122, 98765, 75000 };
|
||||
|
||||
@ -66,7 +66,7 @@ int main(void)
|
||||
start_test = xtimer_now_usec();
|
||||
for (unsigned m = 0; m < RUNS; m++) {
|
||||
for (unsigned n = 0;
|
||||
n < sizeof(sleep_times) / sizeof(sleep_times[0]);
|
||||
n < ARRAY_SIZE(sleep_times);
|
||||
n++) {
|
||||
|
||||
uint32_t start_sleep, diff;
|
||||
|
Loading…
Reference in New Issue
Block a user