From 4946925bea77a4aace6c310b2b724cf2095c6719 Mon Sep 17 00:00:00 2001 From: Zachary T Welch Date: Tue, 24 Nov 2009 20:32:10 -0800 Subject: 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. --- src/jtag/ft2232.c | 4 ++-- src/jtag/rlink/rlink_speed_table.c | 2 +- src/jtag/tcl.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/jtag') diff --git a/src/jtag/ft2232.c b/src/jtag/ft2232.c index 73cbaf3c..29b6389c 100644 --- a/src/jtag/ft2232.c +++ b/src/jtag/ft2232.c @@ -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]); diff --git a/src/jtag/rlink/rlink_speed_table.c b/src/jtag/rlink/rlink_speed_table.c index 5c40ab46..2ef62ee3 100644 --- a/src/jtag/rlink/rlink_speed_table.c +++ b/src/jtag/rlink/rlink_speed_table.c @@ -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); diff --git a/src/jtag/tcl.c b/src/jtag/tcl.c index bc290788..e755dd7e 100644 --- a/src/jtag/tcl.c +++ b/src/jtag/tcl.c @@ -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; -- cgit v1.2.3