cbmem: Fix console banner matches
Since the new loglevel markers were added, there will now be a marker character at the beginning of the coreboot banner string, and this will make the existing regular expressions meant to find it fail to match. This patch fixes the problem by just allowing for a single extra character there (any character to avoid the hassle of having to match the marker explicitly). The extra character is optional so that we will still continue to match banners from older versions of coreboot as well. Since the `?` glyph is not available in basic POSIX regular expressions, we have to switch to REG_EXTENDED syntax (should otherwise make no difference). (Also, move side effects out of assert() while I'm here, that's not actually safe for the standard libc implementation.) Signed-off-by: Julius Werner <jwerner@chromium.org> Change-Id: I99fb347eb1cf7b043a2113dfda7c798d6ee38975 Reviewed-on: https://review.coreboot.org/c/coreboot/+/62720 Reviewed-by: Yu-Ping Wu <yupingso@google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
860672e987
commit
ce87832c66
|
@ -818,8 +818,8 @@ static void dump_console(enum console_print_type type, int max_loglevel, int pri
|
||||||
cursor = previous = 0;
|
cursor = previous = 0;
|
||||||
if (type != CONSOLE_PRINT_FULL) {
|
if (type != CONSOLE_PRINT_FULL) {
|
||||||
#define BANNER_REGEX(stage) \
|
#define BANNER_REGEX(stage) \
|
||||||
"\n\ncoreboot-[^\n]* " stage " starting.*\\.\\.\\.\n"
|
"\n\n.?coreboot-[^\n]* " stage " starting.*\\.\\.\\.\n"
|
||||||
#define OVERFLOW_REGEX(stage) "\n\\*\\*\\* Pre-CBMEM " stage " console overflow"
|
#define OVERFLOW_REGEX(stage) "\n.?\\*\\*\\* Pre-CBMEM " stage " console overflow"
|
||||||
const char *regex[] = { BANNER_REGEX("verstage-before-bootblock"),
|
const char *regex[] = { BANNER_REGEX("verstage-before-bootblock"),
|
||||||
BANNER_REGEX("bootblock"),
|
BANNER_REGEX("bootblock"),
|
||||||
BANNER_REGEX("verstage"),
|
BANNER_REGEX("verstage"),
|
||||||
|
@ -831,7 +831,8 @@ static void dump_console(enum console_print_type type, int max_loglevel, int pri
|
||||||
for (size_t i = 0; !cursor && i < ARRAY_SIZE(regex); i++) {
|
for (size_t i = 0; !cursor && i < ARRAY_SIZE(regex); i++) {
|
||||||
regex_t re;
|
regex_t re;
|
||||||
regmatch_t match;
|
regmatch_t match;
|
||||||
assert(!regcomp(&re, regex[i], 0));
|
int res = regcomp(&re, regex[i], REG_EXTENDED);
|
||||||
|
assert(res == 0);
|
||||||
|
|
||||||
/* Keep looking for matches so we find the last one. */
|
/* Keep looking for matches so we find the last one. */
|
||||||
while (!regexec(&re, console_c + cursor, 1, &match, 0)) {
|
while (!regexec(&re, console_c + cursor, 1, &match, 0)) {
|
||||||
|
|
Loading…
Reference in New Issue