Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/boot: Use address-of operator on section symbols

Clang warns:

arch/powerpc/boot/main.c:107:18: warning: array comparison always
evaluates to a constant [-Wtautological-compare]
if (_initrd_end > _initrd_start) {
^
arch/powerpc/boot/main.c:155:20: warning: array comparison always
evaluates to a constant [-Wtautological-compare]
if (_esm_blob_end <= _esm_blob_start)
^
2 warnings generated.

These are not true arrays, they are linker defined symbols, which are
just addresses. Using the address of operator silences the warning
and does not change the resulting assembly with either clang/ld.lld
or gcc/ld (tested with diff + objdump -Dr).

Reported-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Tested-by: Geoff Levand <geoff@infradead.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200624035920.835571-1-natechancellor@gmail.com

authored by

Nathan Chancellor and committed by
Michael Ellerman
df4232d9 1addb644

+3 -3
+2 -2
arch/powerpc/boot/main.c
··· 104 104 { 105 105 /* If we have an image attached to us, it overrides anything 106 106 * supplied by the loader. */ 107 - if (_initrd_end > _initrd_start) { 107 + if (&_initrd_end > &_initrd_start) { 108 108 printf("Attached initrd image at 0x%p-0x%p\n\r", 109 109 _initrd_start, _initrd_end); 110 110 initrd_addr = (unsigned long)_initrd_start; ··· 152 152 unsigned long esm_blob_addr, esm_blob_size; 153 153 154 154 /* Do we have an ESM (Enter Secure Mode) blob? */ 155 - if (_esm_blob_end <= _esm_blob_start) 155 + if (&_esm_blob_end <= &_esm_blob_start) 156 156 return; 157 157 158 158 printf("Attached ESM blob at 0x%p-0x%p\n\r",
+1 -1
arch/powerpc/boot/ps3.c
··· 127 127 ps3_repository_read_rm_size(&rm_size); 128 128 dt_fixup_memory(0, rm_size); 129 129 130 - if (_initrd_end > _initrd_start) { 130 + if (&_initrd_end > &_initrd_start) { 131 131 setprop_val(chosen, "linux,initrd-start", (u32)(_initrd_start)); 132 132 setprop_val(chosen, "linux,initrd-end", (u32)(_initrd_end)); 133 133 }