[06/16] mem/vma: Use vm_area_list_init where appropriate

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

Details

Message ID 20190705153811.22652-7-gorcunov@gmail.com
State Accepted
Series "mem: Cleanup and fixups"
Commit a289959332fd002af11e1254b39b40d2a673ea43
Headers show

Commit Message

Cyrill Gorcunov July 5, 2019, 3:38 p.m.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 criu/cr-dump.c    | 9 +++------
 criu/proc_parse.c | 7 +------
 2 files changed, 4 insertions(+), 12 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/cr-dump.c b/criu/cr-dump.c
index 7f2e5edfc52a..9b891497b53f 100644
--- a/criu/cr-dump.c
+++ b/criu/cr-dump.c
@@ -109,8 +109,7 @@  void free_mappings(struct vm_area_list *vma_area_list)
 		free(vma_area);
 	}
 
-	INIT_LIST_HEAD(&vma_area_list->h);
-	vma_area_list->nr = 0;
+	vm_area_list_init(vma_area_list);
 }
 
 int collect_mappings(pid_t pid, struct vm_area_list *vma_area_list,
@@ -1139,8 +1138,7 @@  static int pre_dump_one_task(struct pstree_item *item, InventoryEntry *parent_ie
 	struct parasite_dump_misc misc;
 	struct mem_dump_ctl mdc;
 
-	INIT_LIST_HEAD(&vmas.h);
-	vmas.nr = 0;
+	vm_area_list_init(&vmas);
 
 	pr_info("========================================\n");
 	pr_info("Pre-dumping task (pid: %d)\n", pid);
@@ -1221,8 +1219,7 @@  static int dump_one_task(struct pstree_item *item, InventoryEntry *parent_ie)
 	struct proc_posix_timers_stat proc_args;
 	struct mem_dump_ctl mdc;
 
-	INIT_LIST_HEAD(&vmas.h);
-	vmas.nr = 0;
+	vm_area_list_init(&vmas);
 
 	pr_info("========================================\n");
 	pr_info("Dumping task (pid: %d)\n", pid);
diff --git a/criu/proc_parse.c b/criu/proc_parse.c
index f6ebb1fd6f50..4c127f264062 100644
--- a/criu/proc_parse.c
+++ b/criu/proc_parse.c
@@ -705,12 +705,7 @@  int parse_smaps(pid_t pid, struct vm_area_list *vma_area_list,
 	DIR *map_files_dir = NULL;
 	struct bfd f;
 
-	vma_area_list->nr = 0;
-	vma_area_list->nr_aios = 0;
-	vma_area_list->priv_longest = 0;
-	vma_area_list->priv_size = 0;
-	vma_area_list->shared_longest = 0;
-	INIT_LIST_HEAD(&vma_area_list->h);
+	vm_area_list_init(vma_area_list);
 
 	f.fd = open_proc(pid, "smaps");
 	if (f.fd < 0)

Comments

Mike Rapoport July 8, 2019, 12:37 p.m.
On Fri, Jul 05, 2019 at 06:38:01PM +0300, Cyrill Gorcunov wrote:
> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>

Reviewed-by: Mike Rapoport <rppt@linux.ibm.com>

> ---
>  criu/cr-dump.c    | 9 +++------
>  criu/proc_parse.c | 7 +------
>  2 files changed, 4 insertions(+), 12 deletions(-)
> 
> diff --git a/criu/cr-dump.c b/criu/cr-dump.c
> index 7f2e5edfc52a..9b891497b53f 100644
> --- a/criu/cr-dump.c
> +++ b/criu/cr-dump.c
> @@ -109,8 +109,7 @@ void free_mappings(struct vm_area_list *vma_area_list)
>  		free(vma_area);
>  	}
>  
> -	INIT_LIST_HEAD(&vma_area_list->h);
> -	vma_area_list->nr = 0;
> +	vm_area_list_init(vma_area_list);
>  }
>  
>  int collect_mappings(pid_t pid, struct vm_area_list *vma_area_list,
> @@ -1139,8 +1138,7 @@ static int pre_dump_one_task(struct pstree_item *item, InventoryEntry *parent_ie
>  	struct parasite_dump_misc misc;
>  	struct mem_dump_ctl mdc;
>  
> -	INIT_LIST_HEAD(&vmas.h);
> -	vmas.nr = 0;
> +	vm_area_list_init(&vmas);
>  
>  	pr_info("========================================\n");
>  	pr_info("Pre-dumping task (pid: %d)\n", pid);
> @@ -1221,8 +1219,7 @@ static int dump_one_task(struct pstree_item *item, InventoryEntry *parent_ie)
>  	struct proc_posix_timers_stat proc_args;
>  	struct mem_dump_ctl mdc;
>  
> -	INIT_LIST_HEAD(&vmas.h);
> -	vmas.nr = 0;
> +	vm_area_list_init(&vmas);
>  
>  	pr_info("========================================\n");
>  	pr_info("Dumping task (pid: %d)\n", pid);
> diff --git a/criu/proc_parse.c b/criu/proc_parse.c
> index f6ebb1fd6f50..4c127f264062 100644
> --- a/criu/proc_parse.c
> +++ b/criu/proc_parse.c
> @@ -705,12 +705,7 @@ int parse_smaps(pid_t pid, struct vm_area_list *vma_area_list,
>  	DIR *map_files_dir = NULL;
>  	struct bfd f;
>  
> -	vma_area_list->nr = 0;
> -	vma_area_list->nr_aios = 0;
> -	vma_area_list->priv_longest = 0;
> -	vma_area_list->priv_size = 0;
> -	vma_area_list->shared_longest = 0;
> -	INIT_LIST_HEAD(&vma_area_list->h);
> +	vm_area_list_init(vma_area_list);
>  
>  	f.fd = open_proc(pid, "smaps");
>  	if (f.fd < 0)
> -- 
> 2.20.1
> 
> _______________________________________________
> CRIU mailing list
> CRIU@openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
>