]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
api: fix coverity warning about uninitialized variable
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Fri, 27 May 2022 20:58:13 +0000 (14:58 -0600)
committerTom Hromatka <tom.hromatka@oracle.com>
Fri, 27 May 2022 20:58:16 +0000 (14:58 -0600)
CID 258269 (#1 of 1): Uninitialized scalar variable (UNINIT).
uninit_use: Using uninitialized value version.

In _cgroup_create_cgroup(), the (cg_version_t)version is uninitialized
and might be read the version in false path. It worked until now
because the version is assigned in the true path and given that its enum
the checks are not bounded by range, but rather specific.

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

index 99d8b944731f60a37665ed9b4f9d750166cd021e..5b94521557f4981d4d53fe6f71f7933bb044e3fe 100644 (file)
--- a/src/api.c
+++ b/src/api.c
@@ -2431,7 +2431,7 @@ err:
  */
 int cgroup_create_cgroup(struct cgroup *cgroup, int ignore_ownership)
 {
-       enum cg_version_t version;
+       enum cg_version_t version = CGROUP_UNK;
        char *fts_path[2];
        char *base = NULL;
        char *path = NULL;