Hello Julius Werner, Felix Held,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/40240
to review the following change.
Change subject: assert.h: Simplify dead_code() ......................................................................
assert.h: Simplify dead_code()
It turns out the linker's error message already includes the line number of the dead_code() invocation. If we don't include the line number in the identifier for our undefined reference, we don't need individual identifiers at all and can work with a single, global declaration.
Change-Id: Ib63868ce3114c3f839867a3bfb1b03bdb6facf16 Signed-off-by: Nico Huber nico.h@gmx.de --- M src/include/assert.h 1 file changed, 3 insertions(+), 8 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/40/40240/1
diff --git a/src/include/assert.h b/src/include/assert.h index 492629d..7252ab6 100644 --- a/src/include/assert.h +++ b/src/include/assert.h @@ -52,15 +52,10 @@ * 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' */ -#define __dead_code(tag, line) do { \ - extern void dead_code_assertion_failed##tag##_at_line_##line(void) \ - __attribute__((noreturn)); \ - dead_code_assertion_failed##tag##_at_line_##line(); \ -} while (0) -#define _dead_code(tag, line) __dead_code(tag, line) -#define dead_code(tag) _dead_code(tag, __LINE__) +extern void _dead_code_assertion_failed(void) __attribute__((noreturn)); +#define dead_code() _dead_code_assertion_failed()
/* This can be used in the context of an expression of type 'type'. */ #define dead_code_t(type) ({ \
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/40240 )
Change subject: assert.h: Simplify dead_code() ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/c/coreboot/+/40240/1/src/include/assert.h File src/include/assert.h:
https://review.coreboot.org/c/coreboot/+/40240/1/src/include/assert.h@57 PS1, Line 57: extern void _dead_code_assertion_failed(void) __attribute__((noreturn)); function definition argument 'void' should also have an identifier name
Hello build bot (Jenkins), Julius Werner, Felix Held,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/40240
to look at the new patch set (#2).
Change subject: assert.h: Simplify dead_code() ......................................................................
assert.h: Simplify dead_code()
It turns out the linker's error message already includes the line number of the dead_code() invocation. If we don't include the line number in the identifier for our undefined reference, we don't need individual identifiers at all and can work with a single, global declaration.
Change-Id: Ib63868ce3114c3f839867a3bfb1b03bdb6facf16 Signed-off-by: Nico Huber nico.h@gmx.de --- M src/include/assert.h M src/security/vboot/misc.h 2 files changed, 5 insertions(+), 10 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/40/40240/2
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/40240 )
Change subject: assert.h: Simplify dead_code() ......................................................................
Patch Set 2:
(1 comment)
https://review.coreboot.org/c/coreboot/+/40240/2/src/include/assert.h File src/include/assert.h:
https://review.coreboot.org/c/coreboot/+/40240/2/src/include/assert.h@57 PS2, Line 57: extern void _dead_code_assertion_failed(void) __attribute__((noreturn)); function definition argument 'void' should also have an identifier name
Nico Huber has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/40240 )
Change subject: assert.h: Simplify dead_code() ......................................................................
Patch Set 2:
(1 comment)
https://review.coreboot.org/c/coreboot/+/40240/2/src/include/assert.h File src/include/assert.h:
https://review.coreboot.org/c/coreboot/+/40240/2/src/include/assert.h@57 PS2, Line 57: extern void _dead_code_assertion_failed(void) __attribute__((noreturn));
function definition argument 'void' should also have an identifier name
Is that a weird way to tell me to put the attribute before the function name?
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/40240 )
Change subject: assert.h: Simplify dead_code() ......................................................................
Patch Set 2: Code-Review+2
Felix Held has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/40240 )
Change subject: assert.h: Simplify dead_code() ......................................................................
Patch Set 2: Code-Review+1
this looks much cleaner to me
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/40240 )
Change subject: assert.h: Simplify dead_code() ......................................................................
Patch Set 2: Code-Review+2
Angel Pons has submitted this change. ( https://review.coreboot.org/c/coreboot/+/40240 )
Change subject: assert.h: Simplify dead_code() ......................................................................
assert.h: Simplify dead_code()
It turns out the linker's error message already includes the line number of the dead_code() invocation. If we don't include the line number in the identifier for our undefined reference, we don't need individual identifiers at all and can work with a single, global declaration.
Change-Id: Ib63868ce3114c3f839867a3bfb1b03bdb6facf16 Signed-off-by: Nico Huber nico.h@gmx.de Reviewed-on: https://review.coreboot.org/c/coreboot/+/40240 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Julius Werner jwerner@chromium.org Reviewed-by: Felix Held felix-coreboot@felixheld.de Reviewed-by: Angel Pons th3fanbus@gmail.com --- M src/include/assert.h M src/security/vboot/misc.h 2 files changed, 5 insertions(+), 10 deletions(-)
Approvals: build bot (Jenkins): Verified Felix Held: Looks good to me, but someone else must approve Julius Werner: Looks good to me, approved Angel Pons: Looks good to me, approved
diff --git a/src/include/assert.h b/src/include/assert.h index 492629d..7252ab6 100644 --- a/src/include/assert.h +++ b/src/include/assert.h @@ -52,15 +52,10 @@ * 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' */ -#define __dead_code(tag, line) do { \ - extern void dead_code_assertion_failed##tag##_at_line_##line(void) \ - __attribute__((noreturn)); \ - dead_code_assertion_failed##tag##_at_line_##line(); \ -} while (0) -#define _dead_code(tag, line) __dead_code(tag, line) -#define dead_code(tag) _dead_code(tag, __LINE__) +extern void _dead_code_assertion_failed(void) __attribute__((noreturn)); +#define dead_code() _dead_code_assertion_failed()
/* 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(); } }
9elements QA has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/40240 )
Change subject: assert.h: Simplify dead_code() ......................................................................
Patch Set 3:
Automatic boot test returned (PASS/FAIL/TOTAL): 3/0/3 Emulation targets: EMULATION_QEMU_X86_Q35 using payload TianoCore : SUCCESS : https://lava.9esec.io/r/2222 EMULATION_QEMU_X86_Q35 using payload SeaBIOS : SUCCESS : https://lava.9esec.io/r/2221 EMULATION_QEMU_X86_I440FX using payload SeaBIOS : SUCCESS : https://lava.9esec.io/r/2220
Please note: This test is under development and might not be accurate at all!