[PATCH] powerpc: Fix warning with '__powerpc64__'

From: Yu-Chun Lin
Date: Sat Jan 11 2025 - 12:13:34 EST


As reported by the kernel test robot, the following error occurs:

arch/powerpc/lib/sstep.c: In function 'analyse_instr':
>> arch/powerpc/lib/sstep.c:1172:28: warning: variable 'suffix' set but not used [-Wunused-but-set-variable]
1172 | unsigned int word, suffix;
| ^~~~~~
arch/powerpc/lib/sstep.c:1168:38: warning: variable 'rc' set but not used [-Wunused-but-set-variable]
1168 | unsigned int opcode, ra, rb, rc, rd, spr, u;
| ^~

These variables are now conditionally defined with the '__powerpc64__'
macro to ensure they are only used when applicable.

Reported-by: kernel test robot <lkp@xxxxxxxxx>
Closes: https://lore.kernel.org/oe-kbuild-all/202501100247.gEmkqu8j-lkp@xxxxxxxxx/
Signed-off-by: Yu-Chun Lin <eleanor15x@xxxxxxxxx>
---
arch/powerpc/lib/sstep.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index ac3ee19531d8..eea8653464e7 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -1354,15 +1354,21 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
#ifdef CONFIG_PPC64
unsigned int suffixopcode, prefixtype, prefix_r;
#endif
- unsigned int opcode, ra, rb, rc, rd, spr, u;
+ unsigned int opcode, ra, rb, rd, spr, u;
unsigned long int imm;
unsigned long int val, val2;
unsigned int mb, me, sh;
- unsigned int word, suffix;
+ unsigned int word;
+#ifdef __powerpc64__
+ unsigned int suffix;
+ unsigned int rc;
+#endif
long ival;

word = ppc_inst_val(instr);
+#ifdef __powerpc64__
suffix = ppc_inst_suffix(instr);
+#endif

op->type = COMPUTE;

@@ -1480,7 +1486,9 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
rd = (word >> 21) & 0x1f;
ra = (word >> 16) & 0x1f;
rb = (word >> 11) & 0x1f;
+#ifdef __powerpc64__
rc = (word >> 6) & 0x1f;
+#endif

switch (opcode) {
#ifdef __powerpc64__
--
2.43.0