From 8f4b015759cf6189d8f942d7c06bea6a42a06c54 Mon Sep 17 00:00:00 2001 From: Hsuan Ting Chen Date: Thu, 6 Jul 2023 14:15:31 +0800 Subject: lib: Adjust the log levels in ux_locales.c The function ux_locales_get_text() should expect to have a correct preram_locales region to read, hence we need to adjust the log levels inside lib/ux_locales.c:ux_locales_get_text(): * If the region does not exist or is not in a correct format, we should print in BIOS_ERR * If the arguments are not correct but we have a good workaround (e.g. the lang_id from vboot API seems weird), we should print in BIOS_WARNING. Also change some minor syntax issues. BUG=b:264666392, b:289995591 BRANCH=brya TEST=emerge-brya coreboot chromeos-bootimage Signed-off-by: Hsuan Ting Chen Change-Id: Ic8a8856c883f6ca78fed69542a7d388f57c5c508 Reviewed-on: https://review.coreboot.org/c/coreboot/+/76316 Reviewed-by: Eric Lai Tested-by: build bot (Jenkins) Reviewed-by: Yu-Ping Wu --- src/lib/ux_locales.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/lib/ux_locales.c b/src/lib/ux_locales.c index 0ba66ad8cc..86126195b4 100644 --- a/src/lib/ux_locales.c +++ b/src/lib/ux_locales.c @@ -106,7 +106,7 @@ const char *ux_locales_get_text(const char *name) data = locales_get_map(&size, false); if (!data) { - printk(BIOS_INFO, "%s: %s not found.\n", __func__, + printk(BIOS_ERR, "%s: %s not found.\n", __func__, PRERAM_LOCALES_NAME); return NULL; } @@ -115,7 +115,7 @@ const char *ux_locales_get_text(const char *name) lang_id = vb2api_get_locale_id(vboot_get_context()); /* Validity check: Language ID should smaller than LANG_ID_MAX. */ if (lang_id >= LANG_ID_MAX) { - printk(BIOS_INFO, "%s: ID %d too big; fallback to 0.\n", + printk(BIOS_WARNING, "%s: ID %d too big; fallback to 0.\n", __func__, lang_id); lang_id = 0; } @@ -123,11 +123,10 @@ const char *ux_locales_get_text(const char *name) printk(BIOS_INFO, "%s: Search for %s with language ID: %u\n", __func__, name, lang_id); - offset = 0; /* Search for name. */ - offset = search_for(data, offset, size, name); + offset = search_for(data, 0, size, name); if (offset >= size) { - printk(BIOS_INFO, "%s: Name %s not found.\n", __func__, name); + printk(BIOS_ERR, "%s: Name %s not found.\n", __func__, name); return NULL; } name_offset = offset; @@ -145,20 +144,20 @@ const char *ux_locales_get_text(const char *name) if (lang_id != 0) offset = search_for_id(data, name_offset, size, 0); if (offset >= size) { - printk(BIOS_INFO, "%s: Neither %d nor 0 found.\n", + printk(BIOS_ERR, "%s: Neither %d nor 0 found.\n", __func__, lang_id); return NULL; } } - offset = move_next(data, offset, size); + offset = move_next(data, offset, size); if (offset >= size) return NULL; /* Validity check that the returned string must be NULL terminated. */ next = move_next(data, offset, size) - 1; if (next >= size || data[next] != '\0') { - printk(BIOS_INFO, "%s: %s is not NULL terminated.\n", + printk(BIOS_ERR, "%s: %s is not NULL terminated.\n", __func__, PRERAM_LOCALES_NAME); return NULL; } -- cgit v1.2.3