]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Bug #158: Deletion of unnecessary checks before a few calls of LXC functions
authorMarkus Elfring <elfring@users.sourceforge.net>
Sat, 24 Jan 2015 19:38:49 +0000 (20:38 +0100)
committerStéphane Graber <stgraber@ubuntu.com>
Sat, 24 Jan 2015 21:43:56 +0000 (16:43 -0500)
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>
src/lxc/cgfs.c
src/lxc/lxc_autostart.c
src/lxc/lxccontainer.c

index e63978abafe65e9e01703ed10ce0290911b8f6fd..8ff3fb3f5d35f26d58516277789888f37ccd6399 100644 (file)
@@ -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);
 }
 
index 1959e61bc19517e3d1e80baefa3f2527170c0e1d..f5b9e32f95d58a7693a58e9ef46e0c6dcce00513 100644 (file)
@@ -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;
                        }
@@ -501,11 +501,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;
index ee73b64c9b0e9d6db544c987a2fddf783574be8b..c7c4cf8a26cbe0a7e31df537ec4aa27f5e8577b9 100644 (file)
@@ -1378,7 +1378,7 @@ out_unlock:
        if (partial_fd >= 0)
                remove_partial(c, partial_fd);
 out:
-       if (!ret && c)
+       if (!ret)
                container_destroy(c);
 free_tpath:
        free(tpath);