Skip to content

Commit

Permalink
Bug #158: Deletion of unnecessary checks before a few calls of LXC fu…
Browse files Browse the repository at this point in the history
…nctions

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: Markus Elfring <elfring@users.sourceforge.net>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
  • Loading branch information
elfring authored and stgraber committed Aug 28, 2015
1 parent bcbe69f commit 284369c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
6 changes: 2 additions & 4 deletions src/lxc/cgfs.c
Expand Up @@ -2248,10 +2248,8 @@ static void cgfs_destroy(void *hdata)
if (!d)
return;
free(d->name);
if (d->info)
lxc_cgroup_process_info_free_and_remove(d->info);
if (d->meta)
lxc_cgroup_put_meta(d->meta);
lxc_cgroup_process_info_free_and_remove(d->info);
lxc_cgroup_put_meta(d->meta);
free(d);
}

Expand Down
8 changes: 2 additions & 6 deletions src/lxc/lxc_autostart.c
Expand Up @@ -482,7 +482,7 @@ int main(int argc, char *argv[])
if ( lxc_container_put(c) > 0 ) {
containers[i] = NULL;
}
if ( c_groups_lists && c_groups_lists[i] ) {
if ( c_groups_lists ) {
toss_list(c_groups_lists[i]);
c_groups_lists[i] = NULL;
}
Expand All @@ -500,11 +500,7 @@ int main(int argc, char *argv[])
}

free(c_groups_lists);

if ( cmd_groups_list ) {
toss_list( cmd_groups_list );
}

toss_list( cmd_groups_list );
free(containers);

return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/lxc/lxccontainer.c
Expand Up @@ -1370,7 +1370,7 @@ static bool lxcapi_create(struct lxc_container *c, const char *t,
if (partial_fd >= 0)
remove_partial(c, partial_fd);
out:
if (!ret && c)
if (!ret)
lxcapi_destroy(c);
free_tpath:
free(tpath);
Expand Down

0 comments on commit 284369c

Please sign in to comment.