]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
samples: Fix coverity warning in systemd C example
authorTom Hromatka <tom.hromatka@oracle.com>
Mon, 3 Jul 2023 18:24:56 +0000 (12:24 -0600)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 5 Jul 2023 15:03:20 +0000 (09:03 -0600)
Fix the following coverity warning in the systemd C example:

CID 1516634 (#1 of 1): Uninitialized pointer read (UNINIT)5.
uninit_use: Using uninitialized value cg.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
samples/c/create_systemd_scope.c

index 2273d293cde0d7738678fe2d1dd95e1b9ab9ab77..cb77d9b7d43520e1ee4f2acf59e5460f38c64e6d 100644 (file)
@@ -209,10 +209,10 @@ error:
 
 static int move_pids_to_tmp_cgroup(const struct example_opts * const opts)
 {
+       struct cgroup *cg = NULL;
        int ret, pid_cnt, i;
        pid_t *pids = NULL;
        int saved_ret = 0;
-       struct cgroup *cg;
 
        /*
         * Since we told libcgroup that our slice and scope are the default, we can