Commit 06701297 authored by Jianlin Lv's avatar Jianlin Lv Committed by Arnaldo Carvalho de Melo

perf tools: Fix arm64 build error with gcc-11

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: default avatarJianlin Lv <Jianlin.Lv@arm.com>
Reviewed-by: default avatarJohn Garry <john.garry@huawei.com>
Acked-by: default avatarJiri 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.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 865eb3fb
...@@ -15,7 +15,7 @@ void perf_regs_load(u64 *regs); ...@@ -15,7 +15,7 @@ void perf_regs_load(u64 *regs);
#define PERF_REG_IP PERF_REG_ARM_PC #define PERF_REG_IP PERF_REG_ARM_PC
#define PERF_REG_SP PERF_REG_ARM_SP #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) { switch (id) {
case PERF_REG_ARM_R0: case PERF_REG_ARM_R0:
......
...@@ -15,7 +15,7 @@ void perf_regs_load(u64 *regs); ...@@ -15,7 +15,7 @@ void perf_regs_load(u64 *regs);
#define PERF_REG_IP PERF_REG_ARM64_PC #define PERF_REG_IP PERF_REG_ARM64_PC
#define PERF_REG_SP PERF_REG_ARM64_SP #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) { switch (id) {
case PERF_REG_ARM64_X0: case PERF_REG_ARM64_X0:
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#define PERF_REG_IP PERF_REG_CSKY_PC #define PERF_REG_IP PERF_REG_CSKY_PC
#define PERF_REG_SP PERF_REG_CSKY_SP #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) { switch (id) {
case PERF_REG_CSKY_A0: case PERF_REG_CSKY_A0:
......
...@@ -79,7 +79,7 @@ static const char *reg_names[] = { ...@@ -79,7 +79,7 @@ static const char *reg_names[] = {
[PERF_REG_POWERPC_PMC6] = "pmc6", [PERF_REG_POWERPC_PMC6] = "pmc6",
}; };
static inline const char *perf_reg_name(int id) static inline const char *__perf_reg_name(int id)
{ {
return reg_names[id]; return reg_names[id];
} }
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#define PERF_REG_IP PERF_REG_RISCV_PC #define PERF_REG_IP PERF_REG_RISCV_PC
#define PERF_REG_SP PERF_REG_RISCV_SP #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) { switch (id) {
case PERF_REG_RISCV_PC: case PERF_REG_RISCV_PC:
......
...@@ -14,7 +14,7 @@ void perf_regs_load(u64 *regs); ...@@ -14,7 +14,7 @@ void perf_regs_load(u64 *regs);
#define PERF_REG_IP PERF_REG_S390_PC #define PERF_REG_IP PERF_REG_S390_PC
#define PERF_REG_SP PERF_REG_S390_R15 #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) { switch (id) {
case PERF_REG_S390_R0: case PERF_REG_S390_R0:
......
...@@ -23,7 +23,7 @@ void perf_regs_load(u64 *regs); ...@@ -23,7 +23,7 @@ void perf_regs_load(u64 *regs);
#define PERF_REG_IP PERF_REG_X86_IP #define PERF_REG_IP PERF_REG_X86_IP
#define PERF_REG_SP PERF_REG_X86_SP #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) { switch (id) {
case PERF_REG_X86_AX: case PERF_REG_X86_AX:
......
...@@ -33,6 +33,13 @@ extern const struct sample_reg sample_reg_masks[]; ...@@ -33,6 +33,13 @@ extern const struct sample_reg sample_reg_masks[];
int perf_reg_value(u64 *valp, struct regs_dump *regs, int id); 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 #else
#define PERF_REGS_MASK 0 #define PERF_REGS_MASK 0
#define PERF_REGS_MAX 0 #define PERF_REGS_MAX 0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment