Commit c55d4505 by Markus Elfring Committed by Stéphane Graber

Bug #158: Deletion of unnecessary checks before a few calls of LXC functions

The following functions return immediately if a null pointer was passed. * container_destroy * lxc_cgroup_process_info_free_and_remove * lxc_cgroup_put_meta * toss_list It is therefore not needed that a function caller repeats a corresponding check. This issue was fixed by using the software Coccinelle 1.0.0-rc23. Signed-off-by: 's avatarMarkus Elfring <elfring@users.sourceforge.net> Acked-by: 's avatarStéphane Graber <stgraber@ubuntu.com>
parent f10fad2f
...@@ -2248,9 +2248,7 @@ static void cgfs_destroy(void *hdata) ...@@ -2248,9 +2248,7 @@ static void cgfs_destroy(void *hdata)
if (!d) if (!d)
return; return;
free(d->name); free(d->name);
if (d->info)
lxc_cgroup_process_info_free_and_remove(d->info); lxc_cgroup_process_info_free_and_remove(d->info);
if (d->meta)
lxc_cgroup_put_meta(d->meta); lxc_cgroup_put_meta(d->meta);
free(d); free(d);
} }
......
...@@ -482,7 +482,7 @@ int main(int argc, char *argv[]) ...@@ -482,7 +482,7 @@ int main(int argc, char *argv[])
if ( lxc_container_put(c) > 0 ) { if ( lxc_container_put(c) > 0 ) {
containers[i] = NULL; containers[i] = NULL;
} }
if ( c_groups_lists && c_groups_lists[i] ) { if ( c_groups_lists ) {
toss_list(c_groups_lists[i]); toss_list(c_groups_lists[i]);
c_groups_lists[i] = NULL; c_groups_lists[i] = NULL;
} }
...@@ -501,11 +501,7 @@ int main(int argc, char *argv[]) ...@@ -501,11 +501,7 @@ int main(int argc, char *argv[])
} }
free(c_groups_lists); free(c_groups_lists);
if ( cmd_groups_list ) {
toss_list( cmd_groups_list ); toss_list( cmd_groups_list );
}
free(containers); free(containers);
return 0; return 0;
......
...@@ -1378,7 +1378,7 @@ out_unlock: ...@@ -1378,7 +1378,7 @@ out_unlock:
if (partial_fd >= 0) if (partial_fd >= 0)
remove_partial(c, partial_fd); remove_partial(c, partial_fd);
out: out:
if (!ret && c) if (!ret)
container_destroy(c); container_destroy(c);
free_tpath: free_tpath:
free(tpath); free(tpath);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment