Skip to contentSkip to conversation

mm/mmap.c: Remove some redundancy in arch_get_unmapped_area_topdown()

PATCH Superseded Yang Fan 3 participants 6 messages Jan 20, 2019 – Jan 27, 2019

Subsystems (2)
lore
Share & tools
lore

Yang Fan

author
#0 lore raw

cover mm/mmap.c: Remove some redundancy in arch_get_unmapped_area_topdown()

This patchset remove some redundancy in function
arch_get_unmapped_area_topdown().

[PATCH 1/2] mm/mmap.c: Remove redundant variable 'addr' in arch_get_unmapped_area_topdown()
[PATCH 2/2] mm/mmap.c: Remove redundant const qualifier of the no-pointer parameters

Yang Fan (2):
mm/mmap.c: Remove redundant variable 'addr' in
arch_get_unmapped_area_topdown()
mm/mmap.c: Remove redundant const qualifier of the no-pointer
parameters

 mm/mmap.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 1/2 mm/mmap.c: Remove redundant variable 'addr' in arch_get_unmapped_area_topdown()

The variable 'addr' is redundant in arch_get_unmapped_area_topdown(), just use parameter 'addr0' directly. Then remove the const qualifier of the parameter, and change its name to 'addr'.

---
 mm/mmap.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
mm/mmap.c +1 -2
index f901065c4c64..f2d163ac827a 100644
@@ -2126,13 +2126,12 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
  */
 #ifndef HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
 unsigned long
-arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
+arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr,
 			  const unsigned long len, const unsigned long pgoff,
 			  const unsigned long flags)
 {
 	struct vm_area_struct *vma, *prev;
 	struct mm_struct *mm = current->mm;
-	unsigned long addr = addr0;
 	struct vm_unmapped_area_info info;
 	const unsigned long mmap_end = arch_get_mmap_end(addr);
 
Signature · 1 line
2.17.1
author
#3 lore raw

PATCH 2/2 mm/mmap.c: Remove redundant const qualifier of the no-pointer parameters

In reply to Yang Fan

In according with other functions, remove the const qualifier of the no-pointer parameters in function arch_get_unmapped_area_topdown().

---
 mm/mmap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/mmap.c +2 -2
index f2d163ac827a..84cdde125d4d 100644
@@ -2127,8 +2127,8 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
 #ifndef HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
 unsigned long
 arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr,
-			  const unsigned long len, const unsigned long pgoff,
-			  const unsigned long flags)
+			  unsigned long len, unsigned long pgoff,
+			  unsigned long flags)
 {
 	struct vm_area_struct *vma, *prev;
 	struct mm_struct *mm = current->mm;
Signature · 1 line
2.17.1
Reviewed-by on the v1 series
#4 lore raw
In reply to Yang Fan

Hi,

Quoted 8 lines · Yang Fan

This patchset remove some redundancy in function
arch_get_unmapped_area_topdown().

[PATCH 1/2] mm/mmap.c: Remove redundant variable 'addr' in arch_get_unmapped_area_topdown()
[PATCH 2/2] mm/mmap.c: Remove redundant const qualifier of the no-pointer parameters

Quoted 5 lines

Yang Fan (2):
mm/mmap.c: Remove redundant variable 'addr' in
arch_get_unmapped_area_topdown()
mm/mmap.c: Remove redundant const qualifier of the no-pointer
parameters

I think it would be better to merge these patches into one. For the merged patch feel free to add

Quoted 6 lines
 mm/mmap.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
Signature · 1 line
2.17.1
Signature · 2 lines
Sincerely yours,
Mike.
#2 lore raw

Re: [PATCH 1/2] mm/mmap.c: Remove redundant variable 'addr' in arch_get_unmapped_area_topdown()

In reply to Yang Fan
Quoted 9 lines · Yang Fan

The variable 'addr' is redundant in arch_get_unmapped_area_topdown(), just use parameter 'addr0' directly. Then remove the const qualifier of the parameter, and change its name to 'addr'.

These seem similar enough I question whether they really need to be two distinct patches, given both involve removing const keywords from the same routine, and the shift to using the passed addr directly rather than declaring and assigning addr from addr0 is a direct consequence of removing the const.

I could be wrong though and easily persuaded otherwise.

author
#5 lore raw

PATCH v2 1/1 mm/mmap.c: Remove some redundancy in arch_get_unmapped_area_topdown()

In reply to Yang Fan

The variable 'addr' is redundant in arch_get_unmapped_area_topdown(), just use parameter 'addr0' directly. Then remove the const qualifier of the parameter, and change its name to 'addr'.

And in according with other functions, remove the const qualifier of all other no-pointer parameters in function arch_get_unmapped_area_topdown().

---
Changes in v2:
- Merge the two patches into one.

 mm/mmap.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
mm/mmap.c +3 -4
index f901065c4c64..84cdde125d4d 100644
@@ -2126,13 +2126,12 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
  */
 #ifndef HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
 unsigned long
-arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
-			  const unsigned long len, const unsigned long pgoff,
-			  const unsigned long flags)
+arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr,
+			  unsigned long len, unsigned long pgoff,
+			  unsigned long flags)
 {
 	struct vm_area_struct *vma, *prev;
 	struct mm_struct *mm = current->mm;
-	unsigned long addr = addr0;
 	struct vm_unmapped_area_info info;
 	const unsigned long mmap_end = arch_get_mmap_end(addr);
 
Signature · 1 line
2.17.1