Skip to contentSkip to conversation

ARM: arch/arm/kernel/signal.c: resolve set-but-not-used warning

PATCH Superseded Ethan Nelson-Moore 3 participants 4 messages Jun 8 – Jun 9 Arm (32-bit)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: arch/arm/kernel/signal.c: resolve set-but-not-used warning

If neither CONFIG_IWMMXT nor CONFIG_VFP are enabled (which is the case, for example, in rpc_defconfig), the variable "aux" is set but not used, which generates a warning during W=1 builds. Resolve this issue by only defining the variable if it will be used.

---
 arch/arm/kernel/signal.c | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/kernel/signal.c +4 -0
index 7be9188d83d9..1d015b696a76 100644
@@ -140,7 +140,9 @@ static int restore_vfp_context(char __user **auxp)
 static int restore_sigframe(struct pt_regs *regs, struct sigframe __user *sf)
 {
 	struct sigcontext context;
+#if defined(CONFIG_IWMMXT) || defined(CONFIG_VFP)
 	char __user *aux;
+#endif
 	sigset_t set;
 	int err;
 
@@ -171,6 +173,7 @@ static int restore_sigframe(struct pt_regs *regs, struct sigframe __user *sf)
 
 	err |= !valid_user_regs(regs);
 
+#if defined(CONFIG_IWMMXT) || defined(CONFIG_VFP)
 	aux = (char __user *) sf->uc.uc_regspace;
 #ifdef CONFIG_IWMMXT
 	if (err == 0)
@@ -180,6 +183,7 @@ static int restore_sigframe(struct pt_regs *regs, struct sigframe __user *sf)
 	if (err == 0)
 		err |= restore_vfp_context(&aux);
 #endif
+#endif /* defined(CONFIG_IWMMXT) || defined(CONFIG_VFP) */
 
 	return err;
 }
Signature · 1 line
2.43.0
#2 lore raw
In reply to Ethan Nelson-Moore

Hi Ethan,

Quoted 15 lines · Ethan Nelson-Moore

If neither CONFIG_IWMMXT nor CONFIG_VFP are enabled (which is the case, for example, in rpc_defconfig), the variable "aux" is set but not used, which generates a warning during W=1 builds. Resolve this issue by only defining the variable if it will be used.

---
 arch/arm/kernel/signal.c | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/kernel/signal.c +0 -0
index 7be9188d83d9..1d015b696a76 100644

arch/arm/kernel/signal.c static int restore_vfp_context(char __user **auxp) · line 144

Quoted 5 lines
arch/arm/kernel/signal.c +1 -0
@@ -140,7 +140,9 @@ static int restore_vfp_context(char __user **auxp)
 static int restore_sigframe(struct pt_regs *regs, struct sigframe __user *sf)
 {
 	struct sigcontext context;
+#if defined(CONFIG_IWMMXT) || defined(CONFIG_VFP)
 	char __user *aux;

__maybe_unused is a common attribute marking local variables that are not always used. I find it nicer than another layer of #ifdef.

baruch

Quoted 20 lines
arch/arm/kernel/signal.c +3 -0
+#endif
 	sigset_t set;
 	int err;
 
@@ -171,6 +173,7 @@ static int restore_sigframe(struct pt_regs *regs, struct sigframe __user *sf)
 
 	err |= !valid_user_regs(regs);
 
+#if defined(CONFIG_IWMMXT) || defined(CONFIG_VFP)
 	aux = (char __user *) sf->uc.uc_regspace;
 #ifdef CONFIG_IWMMXT
 	if (err == 0)
@@ -180,6 +183,7 @@ static int restore_sigframe(struct pt_regs *regs, struct sigframe __user *sf)
 	if (err == 0)
 		err |= restore_vfp_context(&aux);
 #endif
+#endif /* defined(CONFIG_IWMMXT) || defined(CONFIG_VFP) */
 
 	return err;
 }
Signature · 3 lines
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - [email protected] - tel: +972.52.368.4656, http://www.tkos.co.il -
#3 lore raw

Hi, Baruch,

Quoted 2 lines · Baruch Siach

__maybe_unused is a common attribute marking local variables that are not always used. I find it nicer than another layer of #ifdef.

That's a good point. The compiler will just optimize it out in this case. I'll send a new version of the patch using this attribute.

Ethan