forked from auracaster/openocd
use ARRAY_SIZE macro
Search and destroy lingering cases where the ARRAY_SIZE macro should be used to convey more intrinsic meaning in the OpenOCD code.
This commit is contained in:
@@ -1949,7 +1949,7 @@ static int ft2232_init_ftd2xx(uint16_t vid, uint16_t pid, int more, int* try_mor
|
||||
{
|
||||
static const char* type_str[] =
|
||||
{"BM", "AM", "100AX", "UNKNOWN", "2232C", "232R", "2232H", "4232H"};
|
||||
unsigned no_of_known_types = sizeof(type_str) / sizeof(type_str[0]) - 1;
|
||||
unsigned no_of_known_types = ARRAY_SIZE(type_str) - 1;
|
||||
unsigned type_index = ((unsigned)ftdi_device <= no_of_known_types)
|
||||
? ftdi_device : FT_DEVICE_UNKNOWN;
|
||||
LOG_INFO("device: %lu \"%s\"", ftdi_device, type_str[type_index]);
|
||||
@@ -2034,7 +2034,7 @@ static int ft2232_init_libftdi(uint16_t vid, uint16_t pid, int more, int* try_mo
|
||||
ftdi_device = ftdic.type;
|
||||
static const char* type_str[] =
|
||||
{"AM", "BM", "2232C", "R", "2232H", "4232H", "Unknown"};
|
||||
unsigned no_of_known_types = sizeof(type_str) / sizeof(type_str[0]) - 1;
|
||||
unsigned no_of_known_types = ARRAY_SIZE(type_str) - 1;
|
||||
unsigned type_index = ((unsigned)ftdi_device < no_of_known_types)
|
||||
? ftdi_device : no_of_known_types;
|
||||
LOG_DEBUG("FTDI chip type: %i \"%s\"", (int)ftdi_device, type_str[type_index]);
|
||||
|
||||
@@ -97,5 +97,5 @@ const struct rlink_speed_table rlink_speed_table[] = {{
|
||||
dtc_2, sizeof(dtc_2), (ST7_FOSC * 2) / (1000 * 2), 2
|
||||
}};
|
||||
|
||||
const size_t rlink_speed_table_size = sizeof(rlink_speed_table) / sizeof(*rlink_speed_table);
|
||||
const size_t rlink_speed_table_size = ARRAY_SIZE(rlink_speed_table);
|
||||
|
||||
|
||||
@@ -1304,7 +1304,7 @@ static int Jim_Command_pathmove(Jim_Interp *interp, int argc, Jim_Obj *const *ar
|
||||
{
|
||||
tap_state_t states[8];
|
||||
|
||||
if ((argc < 2) || ((size_t)argc > (sizeof(states)/sizeof(*states) + 1)))
|
||||
if ((argc < 2) || ((size_t)argc > (ARRAY_SIZE(states) + 1)))
|
||||
{
|
||||
Jim_WrongNumArgs(interp, 1, args, "wrong arguments");
|
||||
return JIM_ERR;
|
||||
|
||||
Reference in New Issue
Block a user