]> 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:26:26 +0000 (12:26 -0600)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 5 Jul 2023 15:03:23 +0000 (09:03 -0600)
Fix the following coverity warning in the systemd C example:

CID 1516633 (#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 cb77d9b7d43520e1ee4f2acf59e5460f38c64e6d..cb9ab7d4227b7d73eff6949397d550340c94ca70 100644 (file)
@@ -461,10 +461,10 @@ error:
 
 static int delete_tmp_cgroup(void)
 {
+       struct cgroup *cg = NULL;
        int ret, pid_cnt, i;
        int saved_errno = 0;
        pid_t *pids = NULL;
-       struct cgroup *cg;
 
        ret = cgroup_get_procs(TMP_CGNAME, NULL, &pids, &pid_cnt);
        if (ret) {