From d2397817f12d246cfd88caefd6f12dfd3e2d2c17 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 10 May 2011 07:28:35 +0000 Subject: post: use ARRAY_SIZE We've got a handy dandy macro already for calculating the number of elements in an array, so use it. Signed-off-by: Mike Frysinger --- post/lib_powerpc/andi.c | 3 +-- post/lib_powerpc/cmp.c | 3 +-- post/lib_powerpc/cmpi.c | 3 +-- post/lib_powerpc/cr.c | 12 ++++-------- post/lib_powerpc/fpu/mul-subnormal-single-1.c | 2 +- post/lib_powerpc/load.c | 3 +-- post/lib_powerpc/multi.c | 2 +- post/lib_powerpc/rlwimi.c | 3 +-- post/lib_powerpc/rlwinm.c | 3 +-- post/lib_powerpc/rlwnm.c | 3 +-- post/lib_powerpc/srawi.c | 3 +-- post/lib_powerpc/store.c | 3 +-- post/lib_powerpc/three.c | 3 +-- post/lib_powerpc/threei.c | 3 +-- post/lib_powerpc/threex.c | 3 +-- post/lib_powerpc/two.c | 3 +-- post/lib_powerpc/twox.c | 3 +-- 17 files changed, 20 insertions(+), 38 deletions(-) (limited to 'post/lib_powerpc') diff --git a/post/lib_powerpc/andi.c b/post/lib_powerpc/andi.c index 52ec7c4d4e..2791cd73b1 100644 --- a/post/lib_powerpc/andi.c +++ b/post/lib_powerpc/andi.c @@ -61,8 +61,7 @@ static struct cpu_post_andi_s 0x80000000 }, }; -static unsigned int cpu_post_andi_size = - sizeof (cpu_post_andi_table) / sizeof (struct cpu_post_andi_s); +static unsigned int cpu_post_andi_size = ARRAY_SIZE(cpu_post_andi_table); int cpu_post_test_andi (void) { diff --git a/post/lib_powerpc/cmp.c b/post/lib_powerpc/cmp.c index 5f6a3b9046..ae5b72b2c6 100644 --- a/post/lib_powerpc/cmp.c +++ b/post/lib_powerpc/cmp.c @@ -95,8 +95,7 @@ static struct cpu_post_cmp_s 0x04 }, }; -static unsigned int cpu_post_cmp_size = - sizeof (cpu_post_cmp_table) / sizeof (struct cpu_post_cmp_s); +static unsigned int cpu_post_cmp_size = ARRAY_SIZE(cpu_post_cmp_table); int cpu_post_test_cmp (void) { diff --git a/post/lib_powerpc/cmpi.c b/post/lib_powerpc/cmpi.c index 1a2fc3d094..4160a2aaa1 100644 --- a/post/lib_powerpc/cmpi.c +++ b/post/lib_powerpc/cmpi.c @@ -95,8 +95,7 @@ static struct cpu_post_cmpi_s 0x04 }, }; -static unsigned int cpu_post_cmpi_size = - sizeof (cpu_post_cmpi_table) / sizeof (struct cpu_post_cmpi_s); +static unsigned int cpu_post_cmpi_size = ARRAY_SIZE(cpu_post_cmpi_table); int cpu_post_test_cmpi (void) { diff --git a/post/lib_powerpc/cr.c b/post/lib_powerpc/cr.c index fbee6d5c40..ada7c7af22 100644 --- a/post/lib_powerpc/cr.c +++ b/post/lib_powerpc/cr.c @@ -59,8 +59,7 @@ static ulong cpu_post_cr_table1[] = 0xaaaaaaaa, 0x55555555, }; -static unsigned int cpu_post_cr_size1 = - sizeof (cpu_post_cr_table1) / sizeof (ulong); +static unsigned int cpu_post_cr_size1 = ARRAY_SIZE(cpu_post_cr_table1); static struct cpu_post_cr_s2 { ulong xer; @@ -76,8 +75,7 @@ static struct cpu_post_cr_s2 { 5 }, }; -static unsigned int cpu_post_cr_size2 = - sizeof (cpu_post_cr_table2) / sizeof (struct cpu_post_cr_s2); +static unsigned int cpu_post_cr_size2 = ARRAY_SIZE(cpu_post_cr_table2); static struct cpu_post_cr_s3 { ulong cr; @@ -99,8 +97,7 @@ static struct cpu_post_cr_s3 { 0x71234567 }, }; -static unsigned int cpu_post_cr_size3 = - sizeof (cpu_post_cr_table3) / sizeof (struct cpu_post_cr_s3); +static unsigned int cpu_post_cr_size3 = ARRAY_SIZE(cpu_post_cr_table3); static struct cpu_post_cr_s4 { ulong cmd; @@ -240,8 +237,7 @@ static struct cpu_post_cr_s4 { 0x0000ffff }, }; -static unsigned int cpu_post_cr_size4 = - sizeof (cpu_post_cr_table4) / sizeof (struct cpu_post_cr_s4); +static unsigned int cpu_post_cr_size4 = ARRAY_SIZE(cpu_post_cr_table4); int cpu_post_test_cr (void) { diff --git a/post/lib_powerpc/fpu/mul-subnormal-single-1.c b/post/lib_powerpc/fpu/mul-subnormal-single-1.c index 23a3f302e8..b3f8deb342 100644 --- a/post/lib_powerpc/fpu/mul-subnormal-single-1.c +++ b/post/lib_powerpc/fpu/mul-subnormal-single-1.c @@ -86,7 +86,7 @@ int fpu_post_test_math7 (void) { unsigned int i; - for (i = 0; i < sizeof (expected) / sizeof (expected[0]); i++) + for (i = 0; i < ARRAY_SIZE(expected); i++) { tstmul (expected[i].p1, expected[i].p2, expected[i].res); tstmul (expected[i].p2, expected[i].p1, expected[i].res); diff --git a/post/lib_powerpc/load.c b/post/lib_powerpc/load.c index 98d437318c..49924f2edc 100644 --- a/post/lib_powerpc/load.c +++ b/post/lib_powerpc/load.c @@ -171,8 +171,7 @@ static struct cpu_post_load_s 1 }, }; -static unsigned int cpu_post_load_size = - sizeof (cpu_post_load_table) / sizeof (struct cpu_post_load_s); +static unsigned int cpu_post_load_size = ARRAY_SIZE(cpu_post_load_table); int cpu_post_test_load (void) { diff --git a/post/lib_powerpc/multi.c b/post/lib_powerpc/multi.c index e42a7c07eb..584561684e 100644 --- a/post/lib_powerpc/multi.c +++ b/post/lib_powerpc/multi.c @@ -57,7 +57,7 @@ int cpu_post_test_multi (void) ASM_BLR, }; - for (i = 0; i < sizeof(src) / sizeof(src[0]); i ++) + for (i = 0; i < ARRAY_SIZE(src); ++i) { src[i] = i; dst[i] = 0; diff --git a/post/lib_powerpc/rlwimi.c b/post/lib_powerpc/rlwimi.c index fd628b31f9..15d96aca7b 100644 --- a/post/lib_powerpc/rlwimi.c +++ b/post/lib_powerpc/rlwimi.c @@ -62,8 +62,7 @@ static struct cpu_post_rlwimi_s 0xffaaffff }, }; -static unsigned int cpu_post_rlwimi_size = - sizeof (cpu_post_rlwimi_table) / sizeof (struct cpu_post_rlwimi_s); +static unsigned int cpu_post_rlwimi_size = ARRAY_SIZE(cpu_post_rlwimi_table); int cpu_post_test_rlwimi (void) { diff --git a/post/lib_powerpc/rlwinm.c b/post/lib_powerpc/rlwinm.c index 88a28c6431..a04ec52716 100644 --- a/post/lib_powerpc/rlwinm.c +++ b/post/lib_powerpc/rlwinm.c @@ -59,8 +59,7 @@ static struct cpu_post_rlwinm_s 0x0000ff00 }, }; -static unsigned int cpu_post_rlwinm_size = - sizeof (cpu_post_rlwinm_table) / sizeof (struct cpu_post_rlwinm_s); +static unsigned int cpu_post_rlwinm_size = ARRAY_SIZE(cpu_post_rlwinm_table); int cpu_post_test_rlwinm (void) { diff --git a/post/lib_powerpc/rlwnm.c b/post/lib_powerpc/rlwnm.c index 60bcb6d26c..764fe0c5df 100644 --- a/post/lib_powerpc/rlwnm.c +++ b/post/lib_powerpc/rlwnm.c @@ -60,8 +60,7 @@ static struct cpu_post_rlwnm_s 0x0000ff00 }, }; -static unsigned int cpu_post_rlwnm_size = - sizeof (cpu_post_rlwnm_table) / sizeof (struct cpu_post_rlwnm_s); +static unsigned int cpu_post_rlwnm_size = ARRAY_SIZE(cpu_post_rlwnm_table); int cpu_post_test_rlwnm (void) { diff --git a/post/lib_powerpc/srawi.c b/post/lib_powerpc/srawi.c index be153aded2..90a1e4daad 100644 --- a/post/lib_powerpc/srawi.c +++ b/post/lib_powerpc/srawi.c @@ -61,8 +61,7 @@ static struct cpu_post_srawi_s 0xf0000000 }, }; -static unsigned int cpu_post_srawi_size = - sizeof (cpu_post_srawi_table) / sizeof (struct cpu_post_srawi_s); +static unsigned int cpu_post_srawi_size = ARRAY_SIZE(cpu_post_srawi_table); int cpu_post_test_srawi (void) { diff --git a/post/lib_powerpc/store.c b/post/lib_powerpc/store.c index 1956f6baa3..441389cf4f 100644 --- a/post/lib_powerpc/store.c +++ b/post/lib_powerpc/store.c @@ -156,8 +156,7 @@ static struct cpu_post_store_s 0xff }, }; -static unsigned int cpu_post_store_size = - sizeof (cpu_post_store_table) / sizeof (struct cpu_post_store_s); +static unsigned int cpu_post_store_size = ARRAY_SIZE(cpu_post_store_table); int cpu_post_test_store (void) { diff --git a/post/lib_powerpc/three.c b/post/lib_powerpc/three.c index 7f8c1e2b86..4391386df1 100644 --- a/post/lib_powerpc/three.c +++ b/post/lib_powerpc/three.c @@ -155,8 +155,7 @@ static struct cpu_post_three_s 0x40 }, }; -static unsigned int cpu_post_three_size = - sizeof (cpu_post_three_table) / sizeof (struct cpu_post_three_s); +static unsigned int cpu_post_three_size = ARRAY_SIZE(cpu_post_three_table); int cpu_post_test_three (void) { diff --git a/post/lib_powerpc/threei.c b/post/lib_powerpc/threei.c index 31953f9354..95b6322687 100644 --- a/post/lib_powerpc/threei.c +++ b/post/lib_powerpc/threei.c @@ -75,8 +75,7 @@ static struct cpu_post_threei_s 0xffff8000 }, }; -static unsigned int cpu_post_threei_size = - sizeof (cpu_post_threei_table) / sizeof (struct cpu_post_threei_s); +static unsigned int cpu_post_threei_size = ARRAY_SIZE(cpu_post_threei_table); int cpu_post_test_threei (void) { diff --git a/post/lib_powerpc/threex.c b/post/lib_powerpc/threex.c index 350a12ae78..7769218ba9 100644 --- a/post/lib_powerpc/threex.c +++ b/post/lib_powerpc/threex.c @@ -125,8 +125,7 @@ static struct cpu_post_threex_s 0x1000 }, }; -static unsigned int cpu_post_threex_size = - sizeof (cpu_post_threex_table) / sizeof (struct cpu_post_threex_s); +static unsigned int cpu_post_threex_size = ARRAY_SIZE(cpu_post_threex_table); int cpu_post_test_threex (void) { diff --git a/post/lib_powerpc/two.c b/post/lib_powerpc/two.c index 2b111472b6..7f0888029a 100644 --- a/post/lib_powerpc/two.c +++ b/post/lib_powerpc/two.c @@ -81,8 +81,7 @@ static struct cpu_post_two_s ~5 }, }; -static unsigned int cpu_post_two_size = - sizeof (cpu_post_two_table) / sizeof (struct cpu_post_two_s); +static unsigned int cpu_post_two_size = ARRAY_SIZE(cpu_post_two_table); int cpu_post_test_two (void) { diff --git a/post/lib_powerpc/twox.c b/post/lib_powerpc/twox.c index d6714f9861..88140bf2f5 100644 --- a/post/lib_powerpc/twox.c +++ b/post/lib_powerpc/twox.c @@ -81,8 +81,7 @@ static struct cpu_post_twox_s 12 }, }; -static unsigned int cpu_post_twox_size = - sizeof (cpu_post_twox_table) / sizeof (struct cpu_post_twox_s); +static unsigned int cpu_post_twox_size = ARRAY_SIZE(cpu_post_twox_table); int cpu_post_test_twox (void) { -- cgit v1.2.1