]> git.ipfire.org Git - people/arne_f/kernel.git/commitdiff
perf tools: Fix arm64 build error with gcc-11
authorJianlin Lv <Jianlin.Lv@arm.com>
Thu, 18 Feb 2021 03:12:45 +0000 (11:12 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 3 Sep 2021 08:09:29 +0000 (10:09 +0200)
commit 067012974c8ae31a8886046df082aeba93592972 upstream.

gcc version: 11.0.0 20210208 (experimental) (GCC)

Following build error on arm64:

.......
In function ‘printf’,
    inlined from ‘regs_dump__printf’ at util/session.c:1141:3,
    inlined from ‘regs__printf’ at util/session.c:1169:2:
/usr/include/aarch64-linux-gnu/bits/stdio2.h:107:10: \
  error: ‘%-5s’ directive argument is null [-Werror=format-overflow=]

107 |   return __printf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, \
                __va_arg_pack ());

......
In function ‘fprintf’,
  inlined from ‘perf_sample__fprintf_regs.isra’ at \
    builtin-script.c:622:14:
/usr/include/aarch64-linux-gnu/bits/stdio2.h:100:10: \
    error: ‘%5s’ directive argument is null [-Werror=format-overflow=]
  100 |   return __fprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt,
  101 |                         __va_arg_pack ());

cc1: all warnings being treated as errors
.......

This patch fixes Wformat-overflow warnings. Add helper function to
convert NULL to "unknown".

Signed-off-by: Jianlin Lv <Jianlin.Lv@arm.com>
Reviewed-by: John Garry <john.garry@huawei.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Anju T Sudhakar <anju@linux.vnet.ibm.com>
Cc: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
Cc: Guo Ren <guoren@kernel.org>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: iecedge@gmail.com
Cc: linux-csky@vger.kernel.org
Cc: linux-riscv@lists.infradead.org
Link: http://lore.kernel.org/lkml/20210218031245.2078492-1-Jianlin.Lv@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Hanjun Guo <guohanjun@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
tools/perf/arch/arm/include/perf_regs.h
tools/perf/arch/arm64/include/perf_regs.h
tools/perf/arch/csky/include/perf_regs.h
tools/perf/arch/powerpc/include/perf_regs.h
tools/perf/arch/riscv/include/perf_regs.h
tools/perf/arch/s390/include/perf_regs.h
tools/perf/arch/x86/include/perf_regs.h
tools/perf/util/perf_regs.h

index ed20e0253e25d44a9e7ec6536a45200c6fa0d411..4085419283d07501ef9c5601d7a351b75c46dabe 100644 (file)
@@ -15,7 +15,7 @@ void perf_regs_load(u64 *regs);
 #define PERF_REG_IP    PERF_REG_ARM_PC
 #define PERF_REG_SP    PERF_REG_ARM_SP
 
-static inline const char *perf_reg_name(int id)
+static inline const char *__perf_reg_name(int id)
 {
        switch (id) {
        case PERF_REG_ARM_R0:
index baaa5e64a3fb0d21fd33172d78d30932e1e14174..fa3e07459f7688a38543084120687ae1f3d60b36 100644 (file)
@@ -15,7 +15,7 @@ void perf_regs_load(u64 *regs);
 #define PERF_REG_IP    PERF_REG_ARM64_PC
 #define PERF_REG_SP    PERF_REG_ARM64_SP
 
-static inline const char *perf_reg_name(int id)
+static inline const char *__perf_reg_name(int id)
 {
        switch (id) {
        case PERF_REG_ARM64_X0:
index 8f336ea1161af9d495f3d7629b0c6f4b4c2a7db5..25ac3bdcb9d18723c1d8675280842459870a5bc5 100644 (file)
@@ -15,7 +15,7 @@
 #define PERF_REG_IP    PERF_REG_CSKY_PC
 #define PERF_REG_SP    PERF_REG_CSKY_SP
 
-static inline const char *perf_reg_name(int id)
+static inline const char *__perf_reg_name(int id)
 {
        switch (id) {
        case PERF_REG_CSKY_A0:
index 63f3ac91049f771fb4ac8d0240ffce53ad47f6f7..004bed2286931a0fc9289703d92eed009970a09c 100644 (file)
@@ -73,7 +73,7 @@ static const char *reg_names[] = {
        [PERF_REG_POWERPC_SIER3] = "sier3",
 };
 
-static inline const char *perf_reg_name(int id)
+static inline const char *__perf_reg_name(int id)
 {
        return reg_names[id];
 }
index 7a8bcde7a2b1586b9b3309865f107c20e6270720..6b02a767c918f9bfd7cb187bae5d7baae0a5e625 100644 (file)
@@ -19,7 +19,7 @@
 #define PERF_REG_IP    PERF_REG_RISCV_PC
 #define PERF_REG_SP    PERF_REG_RISCV_SP
 
-static inline const char *perf_reg_name(int id)
+static inline const char *__perf_reg_name(int id)
 {
        switch (id) {
        case PERF_REG_RISCV_PC:
index bcfbaed78cc257f15d9820238bc1ef58256f1c6a..ce30315266239a8cb18d38b013fe563b8b2b33c7 100644 (file)
@@ -14,7 +14,7 @@ void perf_regs_load(u64 *regs);
 #define PERF_REG_IP PERF_REG_S390_PC
 #define PERF_REG_SP PERF_REG_S390_R15
 
-static inline const char *perf_reg_name(int id)
+static inline const char *__perf_reg_name(int id)
 {
        switch (id) {
        case PERF_REG_S390_R0:
index b7321337d10036d577f6434850ccf85b52ade003..cddc4cdc0d9b5f938a32a36ece7b19cdee07c682 100644 (file)
@@ -23,7 +23,7 @@ void perf_regs_load(u64 *regs);
 #define PERF_REG_IP PERF_REG_X86_IP
 #define PERF_REG_SP PERF_REG_X86_SP
 
-static inline const char *perf_reg_name(int id)
+static inline const char *__perf_reg_name(int id)
 {
        switch (id) {
        case PERF_REG_X86_AX:
index a4549912618443cbc3e4f79d94a3861187f25b7a..eeac181ebccf572e725a622393c402a9dcf41763 100644 (file)
@@ -33,6 +33,13 @@ extern const struct sample_reg sample_reg_masks[];
 
 int perf_reg_value(u64 *valp, struct regs_dump *regs, int id);
 
+static inline const char *perf_reg_name(int id)
+{
+       const char *reg_name = __perf_reg_name(id);
+
+       return reg_name ?: "unknown";
+}
+
 #else
 #define PERF_REGS_MASK 0
 #define PERF_REGS_MAX  0