diff options
author | Joel Kitching <kitching@google.com> | 2019-06-25 16:11:45 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-06-26 14:24:47 +0000 |
commit | 98b00ae762cd99aec82757600185b2ae94cdb85f (patch) | |
tree | 51c48bcf1b3b4edb01499d584df35f9cca13d1d9 | |
parent | 9e9619fd4adeeb9409b3ddd25c48c7ff8e7158d6 (diff) | |
download | vboot-98b00ae762cd99aec82757600185b2ae94cdb85f.tar.gz |
vboot: remove vboot1 version of ARRAY_SIZE macro
Macro already exists in vboot2-style 2common.h.
Relocate tests accordingly.
BUG=b:124141368
TEST=make clean && make runtests
BRANCH=none
Change-Id: I6b96627a05e8c05ff49b8780fe4472890c2a2043
Signed-off-by: Joel Kitching <kitching@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1675869
Reviewed-by: Joel Kitching <kitching@chromium.org>
Tested-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
-rw-r--r-- | firmware/lib/include/vboot_common.h | 4 | ||||
-rw-r--r-- | host/lib/crossystem.c | 2 | ||||
-rw-r--r-- | tests/vb2_common_tests.c | 15 | ||||
-rw-r--r-- | tests/vboot_api_kernel4_tests.c | 1 | ||||
-rw-r--r-- | tests/vboot_common_tests.c | 13 |
5 files changed, 17 insertions, 18 deletions
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 @@ -11,6 +11,20 @@ #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(); |