diff --git a/drivers/io/io_fip.c b/drivers/io/io_fip.c index 0cec804..9dcd901 100644 --- a/drivers/io/io_fip.c +++ b/drivers/io/io_fip.c @@ -143,7 +143,7 @@ int i; int status = -EINVAL; - for (i = 0; i < (sizeof(name_uuid) / sizeof(name_uuid[0])); i++) { + for (i = 0; i < ARRAY_SIZE(name_uuid); i++) { if (strcmp(filename, name_uuid[i].name) == 0) { copy_uuid(uuid, &name_uuid[i].uuid); status = 0; diff --git a/include/common/bl_common.h b/include/common/bl_common.h index 0959c89..b36c9d3 100644 --- a/include/common/bl_common.h +++ b/include/common/bl_common.h @@ -108,6 +108,8 @@ #include #include +#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) + /******************************************************************************* * Structure used for telling the next BL how much of a particular type of * memory is available for its use and how much is already used. diff --git a/lib/aarch64/xlat_tables.c b/lib/aarch64/xlat_tables.c index ddc9ba8..fa1a03d 100644 --- a/lib/aarch64/xlat_tables.c +++ b/lib/aarch64/xlat_tables.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -89,7 +90,7 @@ unsigned long size, unsigned attr) { mmap_region_t *mm = mmap; - mmap_region_t *mm_last = mm + sizeof(mmap) / sizeof(mmap[0]) - 1; + mmap_region_t *mm_last = mm + ARRAY_SIZE(mmap) - 1; unsigned long pa_end = base_pa + size - 1; unsigned long va_end = base_va + size - 1; diff --git a/plat/fvp/aarch64/fvp_common.c b/plat/fvp/aarch64/fvp_common.c index fcda2a8..ddaacba 100644 --- a/plat/fvp/aarch64/fvp_common.c +++ b/plat/fvp/aarch64/fvp_common.c @@ -115,7 +115,7 @@ }; #endif -CASSERT((sizeof(fvp_mmap)/sizeof(fvp_mmap[0])) + FVP_BL_REGIONS \ +CASSERT(ARRAY_SIZE(fvp_mmap) + FVP_BL_REGIONS \ <= MAX_MMAP_REGIONS, assert_max_mmap_regions); /* Array of secure interrupts to be configured by the gic driver */ @@ -132,9 +132,6 @@ IRQ_SEC_SGI_7 }; -const unsigned int num_sec_irqs = sizeof(irq_sec_array) / - sizeof(irq_sec_array[0]); - /******************************************************************************* * Macro generating the code for the function setting up the pagetables as per * the platform memory map & initialize the mmu, for the given exception level @@ -326,7 +323,7 @@ plat_config.gicd_base, BASE_GICR_BASE, irq_sec_array, - num_sec_irqs); + ARRAY_SIZE(irq_sec_array)); } diff --git a/plat/juno/aarch64/juno_common.c b/plat/juno/aarch64/juno_common.c index 6ea0b15..371323e 100644 --- a/plat/juno/aarch64/juno_common.c +++ b/plat/juno/aarch64/juno_common.c @@ -114,7 +114,7 @@ }; #endif -CASSERT((sizeof(juno_mmap)/sizeof(juno_mmap[0])) + JUNO_BL_REGIONS \ +CASSERT(ARRAY_SIZE(juno_mmap) + JUNO_BL_REGIONS \ <= MAX_MMAP_REGIONS, assert_max_mmap_regions); /* Array of secure interrupts to be configured by the gic driver */ @@ -136,9 +136,6 @@ IRQ_SEC_SGI_7 }; -const unsigned int num_sec_irqs = sizeof(irq_sec_array) / - sizeof(irq_sec_array[0]); - /******************************************************************************* * Macro generating the code for the function setting up the pagetables as per * the platform memory map & initialize the mmu, for the given exception level @@ -211,5 +208,9 @@ void plat_gic_init(void) { - arm_gic_init(GICC_BASE, GICD_BASE, 0, irq_sec_array, num_sec_irqs); + arm_gic_init(GICC_BASE, + GICD_BASE, + 0, + irq_sec_array, + ARRAY_SIZE(irq_sec_array)); }