coding style: use ARRAY_SIZE() when possible
We have the macro ARRAY_SIZE() already available. Use it! Issue identified by checkpatch script from Linux kernel v5.1 using the command find src/ -type f -exec ./tools/scripts/checkpatch.pl \ -q --types ARRAY_SIZE -f {} \; Change-Id: Ic7da9b710edf118eacb08f9e222f34208c580842 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5198 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
This commit is contained in:
parent
8105c46ba5
commit
1492a103db
|
@ -253,8 +253,7 @@ static int ambiqmicro_read_part_info(struct flash_bank *bank)
|
|||
|
||||
}
|
||||
|
||||
if (ambiqmicro_info->target_class <
|
||||
(sizeof(ambiqmicroParts)/sizeof(ambiqmicroParts[0])))
|
||||
if (ambiqmicro_info->target_class < ARRAY_SIZE(ambiqmicroParts))
|
||||
ambiqmicro_info->target_name =
|
||||
ambiqmicroParts[ambiqmicro_info->target_class].partname;
|
||||
else
|
||||
|
|
|
@ -1663,7 +1663,7 @@ static int numicro_get_cpu_type(struct target *target, const struct numicro_cpu_
|
|||
|
||||
LOG_INFO("Device ID: 0x%08" PRIx32 "", part_id);
|
||||
/* search part numbers */
|
||||
for (size_t i = 0; i < sizeof(NuMicroParts)/sizeof(NuMicroParts[0]); i++) {
|
||||
for (size_t i = 0; i < ARRAY_SIZE(NuMicroParts); i++) {
|
||||
if (part_id == NuMicroParts[i].partid) {
|
||||
*cpu = &NuMicroParts[i];
|
||||
LOG_INFO("Device Name: %s", (*cpu)->partname);
|
||||
|
|
|
@ -108,7 +108,7 @@ static const struct row_region safe_sflash_regions[] = {
|
|||
{0x16007C00, 0x400}, /* SFLASH: TOC2 */
|
||||
};
|
||||
|
||||
#define SFLASH_NUM_REGIONS (sizeof(safe_sflash_regions) / sizeof(safe_sflash_regions[0]))
|
||||
#define SFLASH_NUM_REGIONS ARRAY_SIZE(safe_sflash_regions)
|
||||
|
||||
static struct working_area *g_stack_area;
|
||||
static struct armv7m_algorithm g_armv7m_info;
|
||||
|
|
|
@ -48,7 +48,7 @@ uint8_t usbtoxxx_abilities[USB_TO_XXX_ABILITIES_LEN];
|
|||
|
||||
#define usbtoxxx_get_type_name(type) \
|
||||
types_name[((type) - VERSALOON_USB_TO_XXX_CMD_START) \
|
||||
% (sizeof(types_name) / sizeof(types_name[0]))]
|
||||
% ARRAY_SIZE(types_name)]
|
||||
|
||||
static uint8_t type_pre;
|
||||
static uint16_t usbtoxxx_buffer_index;
|
||||
|
|
Loading…
Reference in New Issue