Skip to contentSkip to conversation

mm: remove unused variable

PATCH In review Bartosz Golaszewski 4 participants 4 messages Mar 12, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: remove unused variable

From: Bartosz Golaszewski <[email protected]>

The mm variable is set but unused. Remove it.

---
 mm/mprotect.c | 1 -
 1 file changed, 1 deletion(-)
mm/mprotect.c +0 -1
index 028c724dcb1a..130dac3ad04f 100644
@@ -39,7 +39,6 @@ static unsigned long change_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
 		unsigned long addr, unsigned long end, pgprot_t newprot,
 		int dirty_accountable, int prot_numa)
 {
-	struct mm_struct *mm = vma->vm_mm;
 	pte_t *pte, oldpte;
 	spinlock_t *ptl;
 	unsigned long pages = 0;
Signature · 1 line
2.20.1
#1 lore raw
Quoted 3 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

The mm variable is set but unused. Remove it.

It is used. Look further down for calls to set_pte_at().

--
Khalid

Quoted 19 lines
---
 mm/mprotect.c | 1 -
 1 file changed, 1 deletion(-)
mm/mprotect.c +0 -1
index 028c724dcb1a..130dac3ad04f 100644
@@ -39,7 +39,6 @@ static unsigned long change_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
 		unsigned long addr, unsigned long end, pgprot_t newprot,
 		int dirty_accountable, int prot_numa)
 {
-	struct mm_struct *mm = vma->vm_mm;
 	pte_t *pte, oldpte;
 	spinlock_t *ptl;
 	unsigned long pages = 0;
#2 lore raw

wt., 12 mar 2019 o 14:59 Khalid Aziz <[email protected]> napisał(a):

Quoted 17 lines · Bartosz Golaszewski
Quoted 3 lines

From: Bartosz Golaszewski <[email protected]>

The mm variable is set but unused. Remove it.

It is used. Look further down for calls to set_pte_at().

--
Khalid

Quoted 6 lines
---
 mm/mprotect.c | 1 -
 1 file changed, 1 deletion(-)
Quoted 15 lines

mm/mprotect.c static unsigned long change_pte_range(struct vm_area_struct *vma, pmd_t *pmd, · line 44

Quoted 13 lines
mm/mprotect.c +0 -1
index 028c724dcb1a..130dac3ad04f 100644
@@ -39,7 +39,6 @@ static unsigned long change_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
              unsigned long addr, unsigned long end, pgprot_t newprot,
              int dirty_accountable, int prot_numa)
 {
-     struct mm_struct *mm = vma->vm_mm;
      pte_t *pte, oldpte;
      spinlock_t *ptl;
      unsigned long pages = 0;

Oops, I blindly assumed the compiler is right, sorry for that. GCC complains it's unused when building usermode linux. I guess it's a matter of how set_pte_at() is defined for ARCH=um. I'll take a second look.

Bart

maintainer
#3 lore raw
Quoted 34 lines · On Tue, 12 Mar 2019 15:03:52 +0100 Bartosz Golaszewski…

wt., 12 mar 2019 o 14:59 Khalid Aziz <[email protected]> napisał(a):

Quoted 17 lines · Bartosz Golaszewski
Quoted 3 lines

From: Bartosz Golaszewski <[email protected]>

The mm variable is set but unused. Remove it.

It is used. Look further down for calls to set_pte_at().

--
Khalid

Quoted 6 lines
---
 mm/mprotect.c | 1 -
 1 file changed, 1 deletion(-)
Quoted 15 lines

mm/mprotect.c static unsigned long change_pte_range(struct vm_area_struct *vma, pmd_t *pmd, · line 44

Quoted 13 lines
mm/mprotect.c +0 -1
index 028c724dcb1a..130dac3ad04f 100644
@@ -39,7 +39,6 @@ static unsigned long change_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
              unsigned long addr, unsigned long end, pgprot_t newprot,
              int dirty_accountable, int prot_numa)
 {
-     struct mm_struct *mm = vma->vm_mm;
      pte_t *pte, oldpte;
      spinlock_t *ptl;
      unsigned long pages = 0;
Quoted 5 lines

Oops, I blindly assumed the compiler is right, sorry for that. GCC complains it's unused when building usermode linux. I guess it's a matter of how set_pte_at() is defined for ARCH=um. I'll take a second look.

The problem is that set_pte_at() is implemented as a macro on some architectures.

The appropriate fix is to make all architectures use a static inline C functions in all cases. That will make the compiler think that the `mm' arg is used, even if it is not.