[CRIU] [PATCH 2/2] free(): don't check arg for non-NULL
Kir Kolyshkin
kir at openvz.org
Mon Oct 19 17:27:22 PDT 2015
This removes a few useless checks of argument passed to free()
to be non-NULL. Calling free(NULL) is just fine.
Signed-off-by: Kir Kolyshkin <kir at openvz.org>
---
lib/criu.c | 18 ++++++------------
proc_parse.c | 6 ++----
2 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/lib/criu.c b/lib/criu.c
index 9c00a0f..0f1d95f 100644
--- a/lib/criu.c
+++ b/lib/criu.c
@@ -546,8 +546,7 @@ int criu_local_add_cg_root(criu_opts *opts, char *ctrl, char *path)
er_p:
free(root->path);
er_c:
- if (root->ctrl)
- free(root->ctrl);
+ free(root->ctrl);
er_r:
free(root);
er:
@@ -624,10 +623,8 @@ int criu_local_add_enable_fs(criu_opts *opts, char *fs)
return 0;
err:
- if (str)
- free(str);
- if (ptr)
- free(ptr);
+ free(str);
+ free(ptr);
return -ENOMEM;
}
@@ -661,10 +658,8 @@ int criu_local_add_skip_mnt(criu_opts *opts, char *mnt)
return 0;
err:
- if (str)
- free(str);
- if (ptr)
- free(ptr);
+ free(str);
+ free(ptr);
return -ENOMEM;
}
@@ -695,8 +690,7 @@ int criu_local_add_irmap_path(criu_opts *opts, char *path)
return 0;
err:
- if (my_path)
- free(my_path);
+ free(my_path);
return -ENOMEM;
}
diff --git a/proc_parse.c b/proc_parse.c
index 7996745..fa11dcf 100644
--- a/proc_parse.c
+++ b/proc_parse.c
@@ -1188,8 +1188,7 @@ struct mount_info *parse_mountinfo(pid_t pid, struct ns_id *nsid, bool for_dump)
}
}
end:
- if (fsname)
- free(fsname);
+ free(fsname);
if (new) {
new->next = list;
@@ -1233,8 +1232,7 @@ static int alloc_fhandle(FhEntry *fh)
static void free_fhandle(FhEntry *fh)
{
- if (fh->handle)
- free(fh->handle);
+ free(fh->handle);
}
void free_inotify_wd_entry(union fdinfo_entries *e)
--
2.4.3
More information about the CRIU
mailing list