Subject: gcc trunk fails to build kernel on PowerPC64 due to oprofile warnings

From: Anton Blanchard <[email-masked]>
Date: Thu, 26 Jan 2017 10:00:44 +1100

Hi,

gcc trunk has failed to build PowerPC64 kernels for a month or so. The issue
is in oprofile, which is common code but ends up being sucked into
arch/powerpc and therefore subject to the -Werror applied to arch/powerpc:
 
linux/arch/powerpc/oprofile/../../../drivers/oprofile/oprofile_stats.c: In function ‘oprofile_create_stats_files’:
linux/arch/powerpc/oprofile/../../../drivers/oprofile/oprofile_stats.c:55:25: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 7 [-Werror=format-truncation=]
   snprintf(buf, 10, "cpu%d", i);
                         ^~
linux/arch/powerpc/oprofile/../../../drivers/oprofile/oprofile_stats.c:55:21: note: using the range [1, -2147483648] for directive argument
   snprintf(buf, 10, "cpu%d", i);
                     ^~~~~~~
linux/arch/powerpc/oprofile/../../../drivers/oprofile/oprofile_stats.c:55:3: note: format output between 5 and 15 bytes into a destination of size 10
   snprintf(buf, 10, "cpu%d", i);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  LD      crypto/async_tx/built-in.o
  CC      lib/random32.o
cc1: all warnings being treated as errors

Anton