diff --git a/firmware/lib/include/vboot_common.h b/firmware/lib/include/vboot_common.h index a3d1851a..b01ed3b2 100644 --- a/firmware/lib/include/vboot_common.h +++ b/firmware/lib/include/vboot_common.h @@ -11,10 +11,6 @@ #include "2api.h" #include "vboot_struct.h" -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(array) (sizeof(array)/sizeof(array[0])) -#endif - /* Test an important condition at compile time, not run time */ #ifndef BUILD_ASSERT #define _BA1_(cond, line) \ diff --git a/host/lib/crossystem.c b/host/lib/crossystem.c index 1eb540a3..2b13258f 100644 --- a/host/lib/crossystem.c +++ b/host/lib/crossystem.c @@ -18,6 +18,7 @@ #include "2sysincludes.h" #include "2api.h" +#include "2common.h" #include "2nvstorage.h" #include "host_common.h" @@ -26,7 +27,6 @@ #include "crossystem_arch.h" #include "crossystem_vbnv.h" #include "utility.h" -#include "vboot_common.h" #include "vboot_struct.h" /* Filename for kernel command line */ diff --git a/tests/vb2_common_tests.c b/tests/vb2_common_tests.c index 3bb24e3b..acc904e9 100644 --- a/tests/vb2_common_tests.c +++ b/tests/vb2_common_tests.c @@ -10,6 +10,20 @@ #include "test_common.h" #include "vboot_struct.h" /* For old struct sizes */ +/* + * Test array size macro. + */ +static void test_array_size(void) +{ + uint8_t arr1[12]; + uint32_t arr2[7]; + uint64_t arr3[9]; + + TEST_EQ(ARRAY_SIZE(arr1), 12, "ARRAYSIZE(uint8_t)"); + TEST_EQ(ARRAY_SIZE(arr2), 7, "ARRAYSIZE(uint32_t)"); + TEST_EQ(ARRAY_SIZE(arr3), 9, "ARRAYSIZE(uint64_t)"); +} + /* * Test struct packing for vboot_struct.h structs which are passed between * firmware and OS, or passed between different phases of firmware. @@ -218,6 +232,7 @@ static void test_helper_functions(void) int main(int argc, char* argv[]) { + test_array_size(); test_struct_packing(); test_memcmp(); test_align(); diff --git a/tests/vboot_api_kernel4_tests.c b/tests/vboot_api_kernel4_tests.c index 5d4370c0..d2f19fa9 100644 --- a/tests/vboot_api_kernel4_tests.c +++ b/tests/vboot_api_kernel4_tests.c @@ -11,6 +11,7 @@ #include "2sysincludes.h" #include "2api.h" +#include "2common.h" #include "2misc.h" #include "2nvstorage.h" #include "ec_sync.h" diff --git a/tests/vboot_common_tests.c b/tests/vboot_common_tests.c index 04d32611..277a44a0 100644 --- a/tests/vboot_common_tests.c +++ b/tests/vboot_common_tests.c @@ -40,18 +40,6 @@ static void StructPackingTest(void) "sizeof(VbSharedDataHeader) V2"); } -/* Test array size macro */ -static void ArraySizeTest(void) -{ - uint8_t arr1[12]; - uint32_t arr2[7]; - uint64_t arr3[9]; - - TEST_EQ(ARRAY_SIZE(arr1), 12, "ARRAYSIZE(uint8_t)"); - TEST_EQ(ARRAY_SIZE(arr2), 7, "ARRAYSIZE(uint32_t)"); - TEST_EQ(ARRAY_SIZE(arr3), 9, "ARRAYSIZE(uint64_t)"); -} - /* Helper functions not dependent on specific key sizes */ static void VerifyHelperFunctions(void) { @@ -222,7 +210,6 @@ static void VbSharedDataTest(void) int main(int argc, char* argv[]) { StructPackingTest(); - ArraySizeTest(); VerifyHelperFunctions(); PublicKeyTest(); VbSharedDataTest();