diff options
-rw-r--r-- | src/flash/avrf.c | 4 | ||||
-rw-r--r-- | src/flash/tms470.c | 12 | ||||
-rw-r--r-- | src/jtag/ft2232.c | 4 | ||||
-rw-r--r-- | src/jtag/rlink/rlink_speed_table.c | 2 | ||||
-rw-r--r-- | src/jtag/tcl.c | 2 | ||||
-rw-r--r-- | src/target/armv7m.c | 4 | ||||
-rw-r--r-- | src/target/avrt.c | 4 | ||||
-rw-r--r-- | src/target/mips32_pracc.c | 30 | ||||
-rw-r--r-- | src/target/mips_ejtag.c | 6 | ||||
-rw-r--r-- | src/target/xscale.c | 4 |
10 files changed, 36 insertions, 36 deletions
diff --git a/src/flash/avrf.c b/src/flash/avrf.c index 1c484643..687dd4b5 100644 --- a/src/flash/avrf.c +++ b/src/flash/avrf.c @@ -290,7 +290,7 @@ static int avrf_probe(struct flash_bank *bank) LOG_ERROR("0x%" PRIx32 " is invalid Manufacturer for avr, 0x%X is expected", EXTRACT_MFG(device_id), 0x1F); } - for (i = 0; i < (int)(sizeof(avft_chips_info) / sizeof(avft_chips_info[0])); i++) + for (i = 0; i < (int)ARRAY_SIZE(avft_chips_info); i++) { if (avft_chips_info[i].chip_id == EXTRACT_PART(device_id)) { @@ -369,7 +369,7 @@ static int avrf_info(struct flash_bank *bank, char *buf, int buf_size) LOG_ERROR("0x%" PRIx32 " is invalid Manufacturer for avr, 0x%X is expected", EXTRACT_MFG(device_id), 0x1F); } - for (i = 0; i < (int)(sizeof(avft_chips_info) / sizeof(avft_chips_info[0])); i++) + for (i = 0; i < (int)ARRAY_SIZE(avft_chips_info); i++) { if (avft_chips_info[i].chip_id == EXTRACT_PART(device_id)) { diff --git a/src/flash/tms470.c b/src/flash/tms470.c index 682013ef..59659346 100644 --- a/src/flash/tms470.c +++ b/src/flash/tms470.c @@ -46,7 +46,7 @@ const struct flash_sector TMS470R1A256_SECTORS[] = { }; #define TMS470R1A256_NUM_SECTORS \ - (sizeof(TMS470R1A256_SECTORS)/sizeof(TMS470R1A256_SECTORS[0])) + ARRAY_SIZE(TMS470R1A256_SECTORS) const struct flash_sector TMS470R1A288_BANK0_SECTORS[] = { {0x00000000, 0x00002000, -1, -1}, @@ -56,7 +56,7 @@ const struct flash_sector TMS470R1A288_BANK0_SECTORS[] = { }; #define TMS470R1A288_BANK0_NUM_SECTORS \ - (sizeof(TMS470R1A288_BANK0_SECTORS)/sizeof(TMS470R1A288_BANK0_SECTORS[0])) + ARRAY_SIZE(TMS470R1A288_BANK0_SECTORS) const struct flash_sector TMS470R1A288_BANK1_SECTORS[] = { {0x00040000, 0x00010000, -1, -1}, @@ -66,7 +66,7 @@ const struct flash_sector TMS470R1A288_BANK1_SECTORS[] = { }; #define TMS470R1A288_BANK1_NUM_SECTORS \ - (sizeof(TMS470R1A288_BANK1_SECTORS)/sizeof(TMS470R1A288_BANK1_SECTORS[0])) + ARRAY_SIZE(TMS470R1A288_BANK1_SECTORS) const struct flash_sector TMS470R1A384_BANK0_SECTORS[] = { {0x00000000, 0x00002000, -1, -1}, @@ -82,7 +82,7 @@ const struct flash_sector TMS470R1A384_BANK0_SECTORS[] = { }; #define TMS470R1A384_BANK0_NUM_SECTORS \ - (sizeof(TMS470R1A384_BANK0_SECTORS)/sizeof(TMS470R1A384_BANK0_SECTORS[0])) + ARRAY_SIZE(TMS470R1A384_BANK0_SECTORS) const struct flash_sector TMS470R1A384_BANK1_SECTORS[] = { {0x00020000, 0x00008000, -1, -1}, @@ -92,7 +92,7 @@ const struct flash_sector TMS470R1A384_BANK1_SECTORS[] = { }; #define TMS470R1A384_BANK1_NUM_SECTORS \ - (sizeof(TMS470R1A384_BANK1_SECTORS)/sizeof(TMS470R1A384_BANK1_SECTORS[0])) + ARRAY_SIZE(TMS470R1A384_BANK1_SECTORS) const struct flash_sector TMS470R1A384_BANK2_SECTORS[] = { {0x00040000, 0x00008000, -1, -1}, @@ -102,7 +102,7 @@ const struct flash_sector TMS470R1A384_BANK2_SECTORS[] = { }; #define TMS470R1A384_BANK2_NUM_SECTORS \ - (sizeof(TMS470R1A384_BANK2_SECTORS)/sizeof(TMS470R1A384_BANK2_SECTORS[0])) + ARRAY_SIZE(TMS470R1A384_BANK2_SECTORS) /* ---------------------------------------------------------------------- */ 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; diff --git a/src/target/armv7m.c b/src/target/armv7m.c index 9d89086e..fc3f47cc 100644 --- a/src/target/armv7m.c +++ b/src/target/armv7m.c @@ -596,7 +596,7 @@ int armv7m_checksum_memory(struct target *target, } /* convert flash writing code into a buffer in target endianness */ - for (i = 0; i < (sizeof(cortex_m3_crc_code)/sizeof(uint16_t)); i++) + for (i = 0; i < ARRAY_SIZE(cortex_m3_crc_code); i++) if ((retval = target_write_u16(target, crc_algorithm->address + i*sizeof(uint16_t), cortex_m3_crc_code[i])) != ERROR_OK) { return retval; @@ -659,7 +659,7 @@ int armv7m_blank_check_memory(struct target *target, } /* convert flash writing code into a buffer in target endianness */ - for (i = 0; i < (sizeof(erase_check_code)/sizeof(uint16_t)); i++) + for (i = 0; i < ARRAY_SIZE(erase_check_code); i++) target_write_u16(target, erase_check_algorithm->address + i*sizeof(uint16_t), erase_check_code[i]); armv7m_info.common_magic = ARMV7M_COMMON_MAGIC; diff --git a/src/target/avrt.c b/src/target/avrt.c index dc527f5e..6ba62068 100644 --- a/src/target/avrt.c +++ b/src/target/avrt.c @@ -196,7 +196,7 @@ int mcu_write_ir(struct jtag_tap *tap, uint8_t *ir_in, uint8_t *ir_out, int ir_l field[0].num_bits = tap->ir_length; field[0].out_value = ir_out; field[0].in_value = ir_in; - jtag_add_plain_ir_scan(sizeof(field) / sizeof(field[0]), field, jtag_set_end_state(TAP_IDLE)); + jtag_add_plain_ir_scan(ARRAY_SIZE(field), field, jtag_set_end_state(TAP_IDLE)); } return ERROR_OK; @@ -217,7 +217,7 @@ int mcu_write_dr(struct jtag_tap *tap, uint8_t *dr_in, uint8_t *dr_out, int dr_l field[0].num_bits = dr_len; field[0].out_value = dr_out; field[0].in_value = dr_in; - jtag_add_plain_dr_scan(sizeof(field) / sizeof(field[0]), field, jtag_set_end_state(TAP_IDLE)); + jtag_add_plain_dr_scan(ARRAY_SIZE(field), field, jtag_set_end_state(TAP_IDLE)); } return ERROR_OK; diff --git a/src/target/mips32_pracc.c b/src/target/mips32_pracc.c index 4f9a7042..604d34ed 100644 --- a/src/target/mips32_pracc.c +++ b/src/target/mips32_pracc.c @@ -348,8 +348,8 @@ int mips32_pracc_read_mem32(struct mips_ejtag *ejtag_info, uint32_t addr, int co param_in[0] = addr; param_in[1] = blocksize; - if ((retval = mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, - sizeof(param_in)/sizeof(param_in[0]), param_in, blocksize, &buf[bytesread], 1)) != ERROR_OK) + if ((retval = mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, + ARRAY_SIZE(param_in), param_in, blocksize, &buf[bytesread], 1)) != ERROR_OK) { return retval; } @@ -387,8 +387,8 @@ int mips32_pracc_read_u32(struct mips_ejtag *ejtag_info, uint32_t addr, uint32_t param_in[0] = addr; - if ((retval = mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, - sizeof(param_in)/sizeof(param_in[0]), param_in, sizeof(uint32_t), buf, 1)) != ERROR_OK) + if ((retval = mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, + ARRAY_SIZE(param_in), param_in, sizeof(uint32_t), buf, 1)) != ERROR_OK) { return retval; } @@ -459,8 +459,8 @@ int mips32_pracc_read_mem16(struct mips_ejtag *ejtag_info, uint32_t addr, int co param_in[0] = addr; param_in[1] = blocksize; - mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, \ - sizeof(param_in)/sizeof(param_in[0]), param_in, count, param_out, 1); + mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, \ + ARRAY_SIZE(param_in), param_in, count, param_out, 1); // count -= blocksize; // addr += blocksize; @@ -540,8 +540,8 @@ int mips32_pracc_read_mem8(struct mips_ejtag *ejtag_info, uint32_t addr, int cou param_in[0] = addr; param_in[1] = blocksize; - mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, \ - sizeof(param_in)/sizeof(param_in[0]), param_in, count, param_out, 1); + mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, \ + ARRAY_SIZE(param_in), param_in, count, param_out, 1); // count -= blocksize; // addr += blocksize; @@ -619,7 +619,7 @@ int mips32_pracc_write_mem32(struct mips_ejtag *ejtag_info, uint32_t addr, int c memcpy(¶m_in[2], buf, count * sizeof(uint32_t)); - mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, \ + mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, \ count + 2, param_in, 0, NULL, 1); free(param_in); @@ -654,8 +654,8 @@ int mips32_pracc_write_u32(struct mips_ejtag *ejtag_info, uint32_t addr, uint32_ param_in[0] = addr; param_in[1] = *buf; - mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, \ - sizeof(param_in)/sizeof(param_in[0]),param_in, 0, NULL, 1); + mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, \ + ARRAY_SIZE(param_in),param_in, 0, NULL, 1); return ERROR_OK; } @@ -714,7 +714,7 @@ int mips32_pracc_write_mem16(struct mips_ejtag *ejtag_info, uint32_t addr, int c param_in[i + 2] = buf[i]; } - mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, \ + mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, \ count + 2, param_in, 0, NULL, 1); free(param_in); @@ -777,7 +777,7 @@ int mips32_pracc_write_mem8(struct mips_ejtag *ejtag_info, uint32_t addr, int co param_in[i + 2] = buf[i]; } - retval = mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, \ + retval = mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, \ count +2, param_in, 0, NULL, 1); free(param_in); @@ -851,7 +851,7 @@ int mips32_pracc_write_regs(struct mips_ejtag *ejtag_info, uint32_t *regs) int retval; - retval = mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, \ + retval = mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, \ 38, regs, 0, NULL, 1); return retval; @@ -928,7 +928,7 @@ int mips32_pracc_read_regs(struct mips_ejtag *ejtag_info, uint32_t *regs) int retval; - retval = mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, \ + retval = mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, \ 0, NULL, 38, regs, 1); return retval; diff --git a/src/target/mips_ejtag.c b/src/target/mips_ejtag.c index 6f06d9a3..68a39faf 100644 --- a/src/target/mips_ejtag.c +++ b/src/target/mips_ejtag.c @@ -143,7 +143,7 @@ int mips_ejtag_step_enable(struct mips_ejtag *ejtag_info) MIPS32_NOP, }; - mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, \ + mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, \ 0, NULL, 0, NULL, 1); return ERROR_OK; @@ -169,7 +169,7 @@ int mips_ejtag_step_disable(struct mips_ejtag *ejtag_info) MIPS32_NOP, }; - mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, \ + mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, \ 0, NULL, 0, NULL, 1); return ERROR_OK; @@ -234,7 +234,7 @@ int mips_ejtag_read_debug(struct mips_ejtag *ejtag_info, uint32_t* debug_reg) MIPS32_NOP, }; - mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, \ + mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, \ 0, NULL, 1, debug_reg, 1); return ERROR_OK; diff --git a/src/target/xscale.c b/src/target/xscale.c index e402a11c..07fcc4c0 100644 --- a/src/target/xscale.c +++ b/src/target/xscale.c @@ -412,7 +412,7 @@ static int xscale_read_tx(struct target *target, int consume) jtag_add_pathmove(3, path); else { - jtag_add_pathmove(sizeof(noconsume_path)/sizeof(*noconsume_path), noconsume_path); + jtag_add_pathmove(ARRAY_SIZE(noconsume_path), noconsume_path); } jtag_add_dr_scan(3, fields, jtag_set_end_state(TAP_IDLE)); @@ -2825,7 +2825,7 @@ static void xscale_build_reg_cache(struct target *target) struct reg_cache **cache_p = register_get_last_cache_p(&target->reg_cache); struct xscale_reg *arch_info = malloc(sizeof(xscale_reg_arch_info)); int i; - int num_regs = sizeof(xscale_reg_arch_info) / sizeof(struct xscale_reg); + int num_regs = ARRAY_SIZE(xscale_reg_arch_info); (*cache_p) = armv4_5_build_reg_cache(target, armv4_5); |