[14/16] mem/shmem: Reorder code in expand_shmem

Submitted by Cyrill Gorcunov on July 5, 2019, 3:38 p.m.

Details

Message ID 20190705153811.22652-15-gorcunov@gmail.com
State New
Series "mem: Cleanup and fixups"
Headers show

Commit Message

Cyrill Gorcunov July 5, 2019, 3:38 p.m.
- more elegant entries declaration
- check for is_shmem_tracking_en early

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 criu/shmem.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/shmem.c b/criu/shmem.c
index da9242674291..478d67a69992 100644
--- a/criu/shmem.c
+++ b/criu/shmem.c
@@ -179,14 +179,15 @@  static void set_pstate(unsigned long *pstate_map, unsigned long pfn,
 
 static int expand_shmem(struct shmem_info *si, unsigned long new_size)
 {
-	unsigned long nr_pages, nr_map_items, map_size,
-				nr_new_map_items, new_map_size, old_size;
+	unsigned long nr_pages, nr_map_items, map_size;
+	unsigned long nr_new_map_items, new_map_size, old_size;
 
-	old_size = si->size;
-	si->size = new_size;
 	if (!is_shmem_tracking_en())
 		return 0;
 
+	old_size = si->size;
+	si->size = new_size;
+
 	nr_pages = DIV_ROUND_UP(old_size, PAGE_SIZE);
 	nr_map_items = BITS_TO_LONGS(nr_pages * PST_BITS);
 	map_size = nr_map_items * sizeof(*si->pstate_map);