diff mbox series

[1/3] mm/swapfile.c: offset is only used when there is more slots

Message ID 20200328060520.31449-2-richard.weiyang@gmail.com (mailing list archive)
State New, archived
Headers show
Series Cleanup scan_swap_map_slots() a little | expand

Commit Message

Wei Yang March 28, 2020, 6:05 a.m. UTC
When si->cluster_nr is zero, function would reach done and return. The
increased offset would not be used any more. This means we can move the
offset increment into the if clause.

This brings a further code cleanup possibility.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
---
 mm/swapfile.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/mm/swapfile.c b/mm/swapfile.c
index 6b6e41967bf3..52afb74fc3d1 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -871,11 +871,9 @@  static int scan_swap_map_slots(struct swap_info_struct *si,
 		else
 			goto done;
 	}
-	/* non-ssd case */
-	++offset;
 
 	/* non-ssd case, still more slots in cluster? */
-	if (si->cluster_nr && !si->swap_map[offset]) {
+	if (si->cluster_nr && !si->swap_map[++offset]) {
 		--si->cluster_nr;
 		goto checks;
 	}