From 2ee6779a64922af755a35ce70f85f2d67b488557 Mon Sep 17 00:00:00 2001 From: Carl-Daniel Hailfinger Date: Wed, 1 Oct 2008 12:52:52 +0000 Subject: The ARRAY_SIZE macro is convenient, yet mostly unused. Switch lots of code to use it. That makes the code more readable and also less error-prone. Abuild tested. Signed-off-by: Carl-Daniel Hailfinger Acked-by: Peter Stuge git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3624 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1 --- src/arch/i386/boot/acpi.c | 2 +- src/arch/i386/boot/coreboot_table.c | 2 +- src/arch/i386/lib/cpu.c | 4 ++-- src/arch/i386/lib/exception.c | 2 +- src/arch/i386/smp/ioapic.c | 2 +- src/arch/ppc/boot/coreboot_table.c | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/arch') diff --git a/src/arch/i386/boot/acpi.c b/src/arch/i386/boot/acpi.c index 46e3291641..a4d17c05bc 100644 --- a/src/arch/i386/boot/acpi.c +++ b/src/arch/i386/boot/acpi.c @@ -44,7 +44,7 @@ void acpi_add_table(acpi_rsdt_t *rsdt, void *table) { int i; - int entries_num = sizeof(rsdt->entry)/sizeof(rsdt->entry[0]); + int entries_num = ARRAY_SIZE(rsdt->entry); for (i=0; ientry[i]==0) { diff --git a/src/arch/i386/boot/coreboot_table.c b/src/arch/i386/boot/coreboot_table.c index 86cb9a388b..427b978d96 100644 --- a/src/arch/i386/boot/coreboot_table.c +++ b/src/arch/i386/boot/coreboot_table.c @@ -184,7 +184,7 @@ void lb_strings(struct lb_header *header) { LB_TAG_ASSEMBLER, coreboot_assembler, }, }; unsigned int i; - for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) { + for(i = 0; i < ARRAY_SIZE(strings); i++) { struct lb_string *rec; size_t len; rec = (struct lb_string *)lb_new_record(header); diff --git a/src/arch/i386/lib/cpu.c b/src/arch/i386/lib/cpu.c index c1b2e5fbf1..6deb1f9393 100644 --- a/src/arch/i386/lib/cpu.c +++ b/src/arch/i386/lib/cpu.c @@ -123,7 +123,7 @@ static const char *cpu_vendor_name(int vendor) { const char *name; name = ""; - if ((vendor < (sizeof(x86_vendor_name)/sizeof(x86_vendor_name[0]))) && + if ((vendor < (ARRAY_SIZE(x86_vendor_name))) && (x86_vendor_name[vendor] != 0)) { name = x86_vendor_name[vendor]; @@ -185,7 +185,7 @@ static void identify_cpu(struct device *cpu) } } cpu->vendor = X86_VENDOR_UNKNOWN; - for(i = 0; i < sizeof(x86_vendors)/sizeof(x86_vendors[0]); i++) { + for(i = 0; i < ARRAY_SIZE(x86_vendors); i++) { if (memcmp(vendor_name, x86_vendors[i].name, 12) == 0) { cpu->vendor = x86_vendors[i].vendor; break; diff --git a/src/arch/i386/lib/exception.c b/src/arch/i386/lib/exception.c index 5f0c4e0563..2d68b918ed 100644 --- a/src/arch/i386/lib/exception.c +++ b/src/arch/i386/lib/exception.c @@ -377,7 +377,7 @@ void x86_exception(struct eregs *info) gdb_stub_registers[CS] = info->cs; gdb_stub_registers[PS] = info->eflags; signo = GDB_UNKNOWN; - if (info->vector < sizeof(exception_to_signal)/sizeof(exception_to_signal[0])) { + if (info->vector < ARRAY_SIZE(exception_to_signal)) { signo = exception_to_signal[info->vector]; } diff --git a/src/arch/i386/smp/ioapic.c b/src/arch/i386/smp/ioapic.c index 87d9a46560..4e72f46f03 100644 --- a/src/arch/i386/smp/ioapic.c +++ b/src/arch/i386/smp/ioapic.c @@ -67,7 +67,7 @@ void setup_ioapic(void) l[0] = 0x03; l[4] = 1; #endif /* i786 */ - for (i = 0; i < sizeof(ioapicregvalues) / sizeof(ioapicregvalues[0]); + for (i = 0; i < ARRAY_SIZE(ioapicregvalues); i++, a++) { l[0] = (a->reg * 2) + 0x10; l[4] = a->value_low; diff --git a/src/arch/ppc/boot/coreboot_table.c b/src/arch/ppc/boot/coreboot_table.c index ea6b683dbc..b1420a7491 100644 --- a/src/arch/ppc/boot/coreboot_table.c +++ b/src/arch/ppc/boot/coreboot_table.c @@ -116,7 +116,7 @@ void lb_strings(struct lb_header *header) { LB_TAG_ASSEMBLER, coreboot_assembler, }, }; unsigned int i; - for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) { + for(i = 0; i < ARRAY_SIZE(strings); i++) { struct lb_string *rec; size_t len; rec = (struct lb_string *)lb_new_record(header); -- cgit v1.2.3