aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/kernel/perf_regs.c
diff options
context:
space:
mode:
authorVasily Gorbik <gor@linux.ibm.com>2018-06-18 17:51:29 +0200
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2018-07-02 11:24:54 +0200
commitad82a928eb58471adb2dec2001f5fbe57e5ee4b5 (patch)
tree87704376889741ce43bac62e0e2bd3e8109a6d5f /arch/s390/kernel/perf_regs.c
parentf6ea4d25e95972f482e14cdcefaa0789e6158d35 (diff)
s390/perf: fix gcc 8 array-bounds warning
arch/s390/kernel/perf_regs.c:36:19: warning: array subscript 16 is above array bounds of 'long unsigned int[16]' [-Warray-bounds] return regs->gprs[idx]; gcc tries to be smart here and since there is a condition: if (idx >= PERF_REG_S390_R0 && idx <= PERF_REG_S390_R15) return regs->gprs[idx]; which covers all possible array subscripts, it gives the warning for the last function return statement: return regs->gprs[idx]; which in presence of that condition does not really make sense and should be replaced with "return 0;" Also move WARN_ON_ONCE((u32)idx >= PERF_REG_S390_MAX) to the end of the function. Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch/s390/kernel/perf_regs.c')
-rw-r--r--arch/s390/kernel/perf_regs.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/arch/s390/kernel/perf_regs.c b/arch/s390/kernel/perf_regs.c
index 54e2d634b849..4352a504f235 100644
--- a/arch/s390/kernel/perf_regs.c
+++ b/arch/s390/kernel/perf_regs.c
@@ -12,9 +12,6 @@ u64 perf_reg_value(struct pt_regs *regs, int idx)
{
freg_t fp;
- if (WARN_ON_ONCE((u32)idx >= PERF_REG_S390_MAX))
- return 0;
-
if (idx >= PERF_REG_S390_R0 && idx <= PERF_REG_S390_R15)
return regs->gprs[idx];
@@ -33,7 +30,8 @@ u64 perf_reg_value(struct pt_regs *regs, int idx)
if (idx == PERF_REG_S390_PC)
return regs->psw.addr;
- return regs->gprs[idx];
+ WARN_ON_ONCE((u32)idx >= PERF_REG_S390_MAX);
+ return 0;
}
#define REG_RESERVED (~((1UL << PERF_REG_S390_MAX) - 1))

Privacy Policy