summaryrefslogtreecommitdiff
path: root/payloads/libpayload/curses/pdcurses-backend/pdcdisp.c
diff options
context:
space:
mode:
authorPaul Menzel <pmenzel@molgen.mpg.de>2021-03-28 21:02:13 +0200
committerPatrick Georgi <pgeorgi@google.com>2021-07-14 08:22:05 +0000
commit1ff60178a90cab2a43a818a45bbc40e4389fd66c (patch)
tree0063c1f8f87a782d1dd82ceaff2fba3adcf0091b /payloads/libpayload/curses/pdcurses-backend/pdcdisp.c
parentb3d24d33606f01fcdda54ba50dc9bbb51e02bac7 (diff)
libpayload: curses: Only call `serial_set_color()` with initialized values
Building nvramcui with i386-elf-gcc (coreboot toolchain v2021-04-06_7014f8258e) 8.3.0 and Link Time Optimization (LTO) enabled in libpayload (`CONFIG_LP_LTO=y`) fails with the error below. LPGCC nvramcui.bin curses/PDCurses/pdcurses/refresh.c: In function 'wrefresh': curses/pdcurses-backend/pdcdisp.c:217:4: error: 'bg' may be used uninitialized in this function [-Werror=maybe-uninitialized] curses/pdcurses-backend/pdcdisp.c:214:18: note: 'bg' was declared here curses/pdcurses-backend/pdcdisp.c:217:4: error: 'fg' may be used uninitialized in this function [-Werror=maybe-uninitialized] curses/pdcurses-backend/pdcdisp.c:214:14: note: 'fg' was declared here lto1: all warnings being treated as errors lto-wrapper: fatal error: i386-elf-gcc returned 1 exit status compilation terminated. /opt/xgcc/lib/gcc/i386-elf/8.3.0/../../../../i386-elf/bin/ld.bfd: error: lto-wrapper failed collect2: error: ld returned 1 exit status `pair_content()` returns in case `PAIR_NUMBER(attr)` is invalid, so guard the usage of `serial_set_color()`. if (pair < 0 || pair >= COLOR_PAIRS || !fg || !bg) return ERR; Note, building with x86_64-linux-gnu-gcc-10 (Debian 10.2.1-6) 10.2.1 20210110 does *not* fail. Change-Id: Ic63e34f2b5bc9f826db37597bebc6b20542481d7 Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de> Reviewed-on: https://review.coreboot.org/c/coreboot/+/51914 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Diffstat (limited to 'payloads/libpayload/curses/pdcurses-backend/pdcdisp.c')
-rw-r--r--payloads/libpayload/curses/pdcurses-backend/pdcdisp.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/payloads/libpayload/curses/pdcurses-backend/pdcdisp.c b/payloads/libpayload/curses/pdcurses-backend/pdcdisp.c
index 234d62a84b..2d05f43767 100644
--- a/payloads/libpayload/curses/pdcurses-backend/pdcdisp.c
+++ b/payloads/libpayload/curses/pdcurses-backend/pdcdisp.c
@@ -212,9 +212,8 @@ void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
if (serial_cur_pair != PAIR_NUMBER(attr)) {
short int fg, bg;
- pair_content(PAIR_NUMBER(attr),
- &fg, &bg);
- serial_set_color(fg, bg);
+ if (pair_content(PAIR_NUMBER(attr), &fg, &bg) == OK)
+ serial_set_color(fg, bg);
serial_cur_pair = PAIR_NUMBER(attr);
}