UPSTREAM: cbmem_console: Fix undefined behavior

Fixes report found by undefined behavior sanitizer. Left shifting an int
where the right operand is >= width of type is undefined. Add
ul suffix since it's safe for unsigned types.

BUG=none
BRANCH=none
TEST=none

Change-Id: I76262ee24dc89fac3d2b027ded72f1f32afaa580
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Original-Commit-Id: fce582fa1c
Original-Change-Id: I4b2365428e421085285006bc1ea8aea75890ff65
Original-Signed-off-by: Ryan Salsamendi <rsalsamendi@hotmail.com>
Original-Reviewed-on: https://review.coreboot.org/20144
Original-Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Original-Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Original-Reviewed-by: Philippe Mathieu-Daud <philippe.mathieu.daude@gmail.com>
Original-Reviewed-by: Martin Roth <martinroth@google.com>
Original-Reviewed-by: Youness Alaoui <snifikino@gmail.com>
Reviewed-on: https://chromium-review.googlesource.com/539203
Commit-Ready: Patrick Georgi <pgeorgi@chromium.org>
Tested-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
This commit is contained in:
Ryan Salsamendi 2017-06-09 19:47:57 -07:00 committed by chrome-bot
commit 878d839596

View file

@ -47,7 +47,7 @@ struct cbmem_console {
#define MAX_SIZE (1 << 28) /* can't be changed without breaking readers! */
#define CURSOR_MASK (MAX_SIZE - 1) /* bits 31-28 are reserved for flags */
#define OVERFLOW (1 << 31) /* set if in ring-buffer mode */
#define OVERFLOW (1UL << 31) /* set if in ring-buffer mode */
_Static_assert(CONFIG_CONSOLE_CBMEM_BUFFER_SIZE <= MAX_SIZE,
"cbmem_console format cannot support buffers larger than 256MB!");