From fce582fa1c928051a3847d35cc334d040159aafb Mon Sep 17 00:00:00 2001 From: Ryan Salsamendi Date: Fri, 9 Jun 2017 19:47:57 -0700 Subject: cbmem_console: Fix undefined behavior MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-on: https://review.coreboot.org/20144 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Martin Roth Reviewed-by: Youness Alaoui --- src/lib/cbmem_console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/lib') 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!"); -- cgit v1.2.3