summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorRyan Salsamendi <rsalsamendi@hotmail.com>2017-06-09 19:47:57 -0700
committerPatrick Georgi <pgeorgi@google.com>2017-06-14 19:51:38 +0200
commitfce582fa1c928051a3847d35cc334d040159aafb (patch)
treed24e33460ba7967c39bcc4bc7c1cf2c0ad139e1e /src/lib
parentf0b071202377e3e4c5550ddaa28a727556745fa7 (diff)
downloadcoreboot-fce582fa1c928051a3847d35cc334d040159aafb.tar.xz
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. Change-Id: I4b2365428e421085285006bc1ea8aea75890ff65 Signed-off-by: Ryan Salsamendi <rsalsamendi@hotmail.com> Reviewed-on: https://review.coreboot.org/20144 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Philippe Mathieu-Daudé <philippe.mathieu.daude@gmail.com> Reviewed-by: Martin Roth <martinroth@google.com> Reviewed-by: Youness Alaoui <snifikino@gmail.com>
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/cbmem_console.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/lib/cbmem_console.c b/src/lib/cbmem_console.c
index b0008b1d9c..34363904b5 100644
--- a/src/lib/cbmem_console.c
+++ b/src/lib/cbmem_console.c
@@ -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!");