Paul Menzel has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/62829 )
Change subject: drivers/pc80/vga: Use write to fix array out of bounds warning ......................................................................
drivers/pc80/vga: Use write to fix array out of bounds warning
CC ramstage/drivers/pc80/vga/vga.o x86_64-linux-gnu-gcc-12 -MMD -Isrc -Isrc/include -Isrc/commonlib/include -Isrc/commonlib/bsd/include -Ibuild -I3rdparty/vboot/firmware/include -include src/include/kconfig.h -include src/include/rules.h -include src/commonlib/bsd/include/commonlib/bsd/compiler.h -I3rdparty -D__BUILD_DIR__="build" -Isrc/arch/x86/include -D__ARCH_x86_32__ -pipe -g -nostdinc -std=gnu11 -nostdlib -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings -Wredundant-decls -Wno-trigraphs -Wimplicit-fallthrough -Wshadow -Wdate-time -Wtype-limits -Wvla -Wdangling-else -fno-common -ffreestanding -fno-builtin -fomit-frame-pointer -fstrict-aliasing -ffunction-sections -fdata-sections -fno-pie -Wno-packed-not-aligned -fconserve-stack -Wnull-dereference -Wreturn-type -Wlogical-op -Wduplicated-cond -Wno-unused-but-set-variable -Werror -Os -Wno-address-of-packed-member -m32 -Wl,-b,elf32-i386 -Wl,-melf_i386 -m32 -fuse-ld=bfd -fno-stack-protector -Wl,--build-id=none -fno-delete-null-pointer-checks -Wlogical-op -march=i686 -mno-mmx -MT build/ramstage/drivers/pc80/vga/vga.o -D__RAMSTAGE__ -c -o build/ramstage/drivers/pc80/vga/vga.o src/drivers/pc80/vga/vga.c src/drivers/pc80/vga/vga.c: In function 'vga_line_write': src/drivers/pc80/vga/vga.c:272:26: error: array subscript [0, 1073741902] is outside array bounds of 'short unsigned int[0]' [-Werror=array-bounds] 272 | p[i] = 0x0F00; | ~^~~ src/drivers/pc80/vga/vga.c:270:26: error: array subscript [0, 1073741902] is outside array bounds of 'short unsigned int[0]' [-Werror=array-bounds] 270 | p[i] = 0x0F00 | string[i]; | ~^~~
Change-Id: Icb60fb4ca08ae39a8628bc2543417819ee9dcbb2 Found-by: gcc-12 (Debian 12-20220313-1) 12.0.1 20220314 (experimental) [master r12-7638-g823b3b79cd2] Signed-off-by: Paul Menzel pmenzel@molgen.mpg.de --- M src/drivers/pc80/vga/vga.c 1 file changed, 3 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/29/62829/1
diff --git a/src/drivers/pc80/vga/vga.c b/src/drivers/pc80/vga/vga.c index dde0355..7f46171 100644 --- a/src/drivers/pc80/vga/vga.c +++ b/src/drivers/pc80/vga/vga.c @@ -3,6 +3,7 @@ #include <pc80/vga.h> #include <pc80/vga_io.h>
+#include <arch/mmio.h> #include <string.h> #include "vga.h"
@@ -267,9 +268,9 @@
for (i = 0; i < 80; i++) { if (i < len) - p[i] = 0x0F00 | string[i]; + write16(p + i, 0x0F00 | string[i]); else - p[i] = 0x0F00; + write16(p + i, 0x0F00); } }