Hello Nico Huber, Angel Pons, Felix Held,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/40237
to review the following change.
Change subject: assert: Use __COUNTER__ instead of tag or line number in dead_code() ......................................................................
assert: Use __COUNTER__ instead of tag or line number in dead_code()
CB:40140 added a 'tag' parameter to dead_code() so that it can be made unique in cases where the line number alone isn't enough. The disadvantage with this is that tags have to be supplied manually. This patch removes both the tag and the line number (which isn't really necessary for readability since the compiler error messages are already good enough to follow on their own) and uses the __COUNTER__ macro instead, which is guaranteed to yield a different number on every invocation.
Signed-off-by: Julius Werner jwerner@chromium.org Change-Id: Ia0837365b0f3a0b1ce599e10e95676b9867982e1 --- M src/include/assert.h M src/security/vboot/misc.h 2 files changed, 8 insertions(+), 8 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/37/40237/1
diff --git a/src/include/assert.h b/src/include/assert.h index 492629d..53f9df4 100644 --- a/src/include/assert.h +++ b/src/include/assert.h @@ -52,15 +52,15 @@ * The error message when this hits will look like this: * * ramstage/lib/bootmode.o: In function `display_init_required': - * bootmode.c:42: undefined reference to `dead_code_assertion_failed_at_line_42' + * bootmode.c:42: undefined reference to `dead_code_assertion_failed_1' */ -#define __dead_code(tag, line) do { \ - extern void dead_code_assertion_failed##tag##_at_line_##line(void) \ +#define __dead_code(ctr) do { \ + extern void dead_code_assertion_failed_##ctr(void) \ __attribute__((noreturn)); \ - dead_code_assertion_failed##tag##_at_line_##line(); \ + dead_code_assertion_failed_##ctr(); \ } while (0) -#define _dead_code(tag, line) __dead_code(tag, line) -#define dead_code(tag) _dead_code(tag, __LINE__) +#define _dead_code(ctr) __dead_code(ctr) +#define dead_code() _dead_code(__COUNTER__)
/* This can be used in the context of an expression of type 'type'. */ #define dead_code_t(type) ({ \ diff --git a/src/security/vboot/misc.h b/src/security/vboot/misc.h index 22cc750..fd422b2 100644 --- a/src/security/vboot/misc.h +++ b/src/security/vboot/misc.h @@ -53,7 +53,7 @@ else if (CONFIG(VBOOT_STARTS_IN_BOOTBLOCK)) return ENV_BOOTBLOCK; else - dead_code(_in_vboot_misc_h); + dead_code(); }
static inline int verstage_should_load(void) @@ -82,7 +82,7 @@ /* Post-RAM stages are "after the romstage" */ return !ENV_ROMSTAGE_OR_BEFORE; } else { - dead_code(_in_vboot_misc_h); + dead_code(); } }