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

sparc: Fix -Wstringop-overflow warning

Greetings,

GCC 7 introduced the -Wstringop-overflow flag to detect buffer overflows
in calls to string handling functions [1][2]. Due to the way
``empty_zero_page'' is declared in arch/sparc/include/setup.h, this
causes a warning to trigger at compile time in the function mem_init(),
which is subsequently converted to an error. The ensuing patch fixes
this issue and aligns the declaration of empty_zero_page to that of
other architectures. Thank you.

Cheers,
Orlando.

[1] https://gcc.gnu.org/ml/gcc-patches/2016-10/msg02308.html
[2] https://gcc.gnu.org/gcc-7/changes.html

Signed-off-by: Orlando Arias <oarias@knights.ucf.edu>

--------------------------------------------------------------------------------
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Orlando Arias and committed by
David S. Miller
deba804c b6c41cb0

+4 -4
+2 -2
arch/sparc/include/asm/pgtable_32.h
··· 91 91 * ZERO_PAGE is a global shared page that is always zero: used 92 92 * for zero-mapped memory areas etc.. 93 93 */ 94 - extern unsigned long empty_zero_page; 94 + extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)]; 95 95 96 - #define ZERO_PAGE(vaddr) (virt_to_page(&empty_zero_page)) 96 + #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page)) 97 97 98 98 /* 99 99 * In general all page table modifications should use the V8 atomic
+1 -1
arch/sparc/include/asm/setup.h
··· 16 16 */ 17 17 extern unsigned char boot_cpu_id; 18 18 19 - extern unsigned long empty_zero_page; 19 + extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)]; 20 20 21 21 extern int serial_console; 22 22 static inline int con_is_present(void)
+1 -1
arch/sparc/mm/init_32.c
··· 290 290 291 291 292 292 /* Saves us work later. */ 293 - memset((void *)&empty_zero_page, 0, PAGE_SIZE); 293 + memset((void *)empty_zero_page, 0, PAGE_SIZE); 294 294 295 295 i = last_valid_pfn >> ((20 - PAGE_SHIFT) + 5); 296 296 i += 1;