summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Kitching <kitching@google.com>2019-09-04 15:42:53 +0800
committerCommit Bot <commit-bot@chromium.org>2019-10-23 16:28:19 +0000
commit3fb27b5f8711671f0d3a24415710fe67cbe0b889 (patch)
tree71729037effe03157494175a506317c1605e1d6c
parent1ff5597e282df81fb2cddcf4b7b47a01553a86fc (diff)
downloadvboot-3fb27b5f8711671f0d3a24415710fe67cbe0b889.tar.gz
vboot: remove BUILD_ASSERT macro
Use _Static_assert() instead. BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: I42a18442a8bff1ab346f8ba784e9e6fc0366de9a Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1786388 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
-rw-r--r--firmware/lib/include/vboot_common.h9
-rw-r--r--futility/file_type_bios.c12
-rw-r--r--futility/futility.h9
-rw-r--r--tests/futility/test_file_types.c3
4 files changed, 10 insertions, 23 deletions
diff --git a/firmware/lib/include/vboot_common.h b/firmware/lib/include/vboot_common.h
index 90678123..ce7fbdfa 100644
--- a/firmware/lib/include/vboot_common.h
+++ b/firmware/lib/include/vboot_common.h
@@ -12,15 +12,6 @@
#include "2struct.h"
#include "vboot_struct.h"
-/* Test an important condition at compile time, not run time */
-#ifndef BUILD_ASSERT
-#define _BA1_(cond, line) \
- extern int __build_assertion_ ## line[1 - 2*!(cond)] \
- __attribute__ ((unused))
-#define _BA0_(c, x) _BA1_(c, x)
-#define BUILD_ASSERT(cond) _BA0_(cond, __LINE__)
-#endif
-
/* Error Codes for all common functions. */
enum {
VBOOT_SUCCESS = 0,
diff --git a/futility/file_type_bios.c b/futility/file_type_bios.c
index fa4874ee..469e46eb 100644
--- a/futility/file_type_bios.c
+++ b/futility/file_type_bios.c
@@ -25,7 +25,8 @@ static const char * const fmap_name[] = {
"VBLOCK_A", /* BIOS_FMAP_VBLOCK_A */
"VBLOCK_B", /* BIOS_FMAP_VBLOCK_B */
};
-BUILD_ASSERT(ARRAY_SIZE(fmap_name) == NUM_BIOS_COMPONENTS);
+_Static_assert(ARRAY_SIZE(fmap_name) == NUM_BIOS_COMPONENTS,
+ "Size of fmap_name[] should match NUM_BIOS_COMPONENTS");
static const char * const fmap_oldname[] = {
"GBB Area", /* BIOS_FMAP_GBB */
@@ -34,7 +35,8 @@ static const char * const fmap_oldname[] = {
"Firmware A Key", /* BIOS_FMAP_VBLOCK_A */
"Firmware B Key", /* BIOS_FMAP_VBLOCK_B */
};
-BUILD_ASSERT(ARRAY_SIZE(fmap_oldname) == NUM_BIOS_COMPONENTS);
+_Static_assert(ARRAY_SIZE(fmap_oldname) == NUM_BIOS_COMPONENTS,
+ "Size of fmap_oldname[] should match NUM_BIOS_COMPONENTS");
static void fmap_limit_area(FmapAreaHeader *ah, uint32_t len)
{
@@ -169,7 +171,8 @@ static int (*fmap_show_fn[])(const char *name, uint8_t *buf, uint32_t len,
ft_show_fw_preamble,
ft_show_fw_preamble,
};
-BUILD_ASSERT(ARRAY_SIZE(fmap_show_fn) == NUM_BIOS_COMPONENTS);
+_Static_assert(ARRAY_SIZE(fmap_show_fn) == NUM_BIOS_COMPONENTS,
+ "Size of fmap_show_fn[] should match NUM_BIOS_COMPONENTS");
int ft_show_bios(const char *name, uint8_t *buf, uint32_t len, void *data)
{
@@ -432,7 +435,8 @@ static int (*fmap_sign_fn[])(const char *name, uint8_t *buf, uint32_t len,
fmap_sign_fw_preamble,
fmap_sign_fw_preamble,
};
-BUILD_ASSERT(ARRAY_SIZE(fmap_sign_fn) == NUM_BIOS_COMPONENTS);
+_Static_assert(ARRAY_SIZE(fmap_sign_fn) == NUM_BIOS_COMPONENTS,
+ "Size of fmap_sign_fn[] should match NUM_BIOS_COMPONENTS");
int ft_sign_bios(const char *name, uint8_t *buf, uint32_t len, void *data)
{
diff --git a/futility/futility.h b/futility/futility.h
index 5dc426dd..d196cee2 100644
--- a/futility/futility.h
+++ b/futility/futility.h
@@ -74,15 +74,6 @@ extern const struct futil_cmd_t *const futil_cmds[];
#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) \
- extern int __build_assertion_ ## line[1 - 2*!(cond)] \
- __attribute__ ((unused))
-#define _BA0_(c, x) _BA1_(c, x)
-#define BUILD_ASSERT(cond) _BA0_(cond, __LINE__)
-#endif
-
/* Fatal error (print error message and exit). */
#define FATAL(format, ...) do { \
fprintf(stderr, "FATAL: %s: " format, __func__, \
diff --git a/tests/futility/test_file_types.c b/tests/futility/test_file_types.c
index 82f51486..3f88872c 100644
--- a/tests/futility/test_file_types.c
+++ b/tests/futility/test_file_types.c
@@ -39,7 +39,8 @@ static struct {
{FILE_TYPE_USBPD1, "tests/futility/data/zinger_mp_image.bin"},
{FILE_TYPE_RWSIG, }, /* need a test for this */
};
-BUILD_ASSERT(ARRAY_SIZE(test_case) == NUM_FILE_TYPES);
+_Static_assert(ARRAY_SIZE(test_case) == NUM_FILE_TYPES,
+ "Need a test case for each file type (total NUM_FILE_TYPES)");
int main(int argc, char *argv[])
{