Skip to contentSkip to conversation

Trivial: Eliminate the ret variable from mm_take_all_locks

PATCH In review Kautuk Consul 2 participants 3 messages Sep 13, 2011 – Sep 21, 2011

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

PATCH 1/1 Trivial: Eliminate the ret variable from mm_take_all_locks

The ret variable is really not needed in mm_take_all_locks as per the current flow of the mm_take_all_locks function.

So, eliminating this return variable.

---
 mm/mmap.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)
mm/mmap.c +3 -5
index a65efd4..48bc056 100644
@@ -2558,7 +2558,6 @@ int mm_take_all_locks(struct mm_struct *mm)
 {
 	struct vm_area_struct *vma;
 	struct anon_vma_chain *avc;
-	int ret = -EINTR;
 
 	BUG_ON(down_read_trylock(&mm->mmap_sem));
 
@@ -2579,13 +2578,12 @@ int mm_take_all_locks(struct mm_struct *mm)
 				vm_lock_anon_vma(mm, avc->anon_vma);
 	}
 
-	ret = 0;
+	return 0;
 
 out_unlock:
-	if (ret)
-		mm_drop_all_locks(mm);
+	mm_drop_all_locks(mm);
 
-	return ret;
+	return -EINTR;
 }
 
 static void vm_unlock_anon_vma(struct anon_vma *anon_vma)
Signature · 8 lines
1.7.6

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Kautuk Consul

The ret variable is really not needed in mm_take_all_locks as per the current flow of the mm_take_all_locks function.

So, eliminating this return variable.

The compiled code seems to be very same - compilers are clever enough to reorganize the code but anyway the code reads better this way.

Quoted 42 lines
---
 mm/mmap.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)
mm/mmap.c +3 -5
index a65efd4..48bc056 100644
@@ -2558,7 +2558,6 @@ int mm_take_all_locks(struct mm_struct *mm)
 {
 	struct vm_area_struct *vma;
 	struct anon_vma_chain *avc;
-	int ret = -EINTR;
 
 	BUG_ON(down_read_trylock(&mm->mmap_sem));
 
@@ -2579,13 +2578,12 @@ int mm_take_all_locks(struct mm_struct *mm)
 				vm_lock_anon_vma(mm, avc->anon_vma);
 	}
 
-	ret = 0;
+	return 0;
 
 out_unlock:
-	if (ret)
-		mm_drop_all_locks(mm);
+	mm_drop_all_locks(mm);
 
-	return ret;
+	return -EINTR;
 }
 
 static void vm_unlock_anon_vma(struct anon_vma *anon_vma)
Signature · 8 lines
1.7.6

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Signature · 13 lines
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9    
Czech Republic

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#2 lore raw

Thanks, Michal.

Quoted 64 lines · Michal Hocko
Quoted 6 lines · Kautuk Consul

The ret variable is really not needed in mm_take_all_locks as per the current flow of the mm_take_all_locks function.

So, eliminating this return variable.

The compiled code seems to be very same - compilers are clever enough to reorganize the code but anyway the code reads better this way.

Quoted 36 lines

---
 mm/mmap.c |    8 +++-----

 1 files changed, 3 insertions(+), 5 deletions(-)
mm/mmap.c +1 -2
index a65efd4..48bc056 100644
@@ -2558,7 +2558,6 @@ int mm_take_all_locks(struct mm_struct *mm)
  {
       struct vm_area_struct *vma;
       struct anon_vma_chain *avc;
-     int ret = -EINTR;
 
       BUG_ON(down_read_trylock(&mm->mmap_sem));
 
@@ -2579,13 +2578,12 @@ int mm_take_all_locks(struct mm_struct *mm)
                               vm_lock_anon_vma(mm, avc->anon_vma);
       }
 
-     ret = 0;
+     return 0;
 

 out_unlock:
-     if (ret)
-             mm_drop_all_locks(mm);
+     mm_drop_all_locks(mm);

-     return ret;
+     return -EINTR;
 }

 static void vm_unlock_anon_vma(struct anon_vma *anon_vma) --
1.7.6

Quoted 6 lines

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

--
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9
Czech Republic