Paul Menzel has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/62827 )
Change subject: lib/cbfs: Compare addresses instead of arrays ......................................................................
lib/cbfs: Compare addresses instead of arrays
GCC 12 warns about the comparison of two arrays:
CC bootblock/lib/cbfs.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/bootblock/lib/cbfs.o -D__BOOTBLOCK__ -c -o build/bootblock/lib/cbfs.o src/lib/cbfs.c src/lib/cbfs.c: In function 'switch_to_postram_cache': src/lib/cbfs.c:31:32: error: comparison between two arrays [-Werror=array-compare] 31 | if (_preram_cbfs_cache != _postram_cbfs_cache) | ^~ src/lib/cbfs.c:31:32: note: use '&_preram_cbfs_cache[0] != &_postram_cbfs_cache[0]' to compare the addresses
Address the warning as suggested by comparing the addresses instead.
Found-by: gcc-12 (Debian 12-20220313-1) 12.0.1 20220314 (experimental) [master r12-7638-g823b3b79cd2] Change-Id: I69310b0bec166faa40f56a36c6d360065cf6b08a Signed-off-by: Paul Menzel pmenzel@molgen.mpg.de --- M src/lib/cbfs.c 1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/27/62827/1
diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c index c8ca14c..615cad4 100644 --- a/src/lib/cbfs.c +++ b/src/lib/cbfs.c @@ -28,7 +28,7 @@
static void switch_to_postram_cache(int unused) { - if (_preram_cbfs_cache != _postram_cbfs_cache) + if (&_preram_cbfs_cache[0] != &_postram_cbfs_cache[0]) mem_pool_init(&cbfs_cache, _postram_cbfs_cache, REGION_SIZE(postram_cbfs_cache), CONFIG_CBFS_CACHE_ALIGN); }