Skip to contentSkip to conversation

x86/mm: fix an unused variable "tsk" warning

PATCH In review Qian Cai 2 participants 2 messages May 31, 2019

Subsystems (2)
lore
Share & tools
lore

Qian Cai

author
#0 lore raw

PATCH 1/1 x86/mm: fix an unused variable "tsk" warning

"tsk" is only used when MEMORY_FAILURE=y.

arch/x86/mm/fault.c: In function 'do_sigbus':
arch/x86/mm/fault.c:1017:22: warning: unused variable 'tsk' [-Wunused-variable]

---
 arch/x86/mm/fault.c | 2 ++
 1 file changed, 2 insertions(+)
arch/x86/mm/fault.c +2 -0
index 46df4c6aae46..a10e518dcdf8 100644
@@ -1015,7 +1015,9 @@ static inline bool bad_area_access_from_pkeys(unsigned long error_code,
 do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
 	  vm_fault_t fault)
 {
+#ifdef CONFIG_MEMORY_FAILURE
 	struct task_struct *tsk = current;
+#endif
 
 	/* Kernel mode? Handle exceptions or die: */
 	if (!(error_code & X86_PF_USER)) {
Signature · 1 line
1.8.3.1
#1 lore raw

arch/x86/mm/fault.c static inline bool bad_area_access_from_pkeys(unsigned long error_code, · line 1023

Quoted 12 lines · Qian Cai
arch/x86/mm/fault.c +2 -0
@@ -1015,7 +1015,9 @@ static inline bool bad_area_access_from_pkeys(unsigned long error_code,
 do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
 	  vm_fault_t fault)
 {
+#ifdef CONFIG_MEMORY_FAILURE
 	struct task_struct *tsk = current;
+#endif
 
 	/* Kernel mode? Handle exceptions or die: */
 	if (!(error_code & X86_PF_USER)) {

Ick. I'd much rather see this:

#ifdef CONFIG_MEMORY_FAILURE
        if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
                unsigned lsb = 0;

become:

        if (IS_ENABLED(CONFIG_MEMORY_FAILURE) &&
 	    (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE))) {
                unsigned lsb = 0;

than add another #ifdef.

BTW, which tree are you doing this against? Current -linus uses tsk in the last line of do_sigbus():

        force_sig_fault(SIGBUS, BUS_ADRERR, ..., tsk);