From: Kamalesh Babulal Date: Fri, 27 May 2022 20:56:42 +0000 (-0600) Subject: api: fix coverity warning about uninitialized variable X-Git-Tag: v3.0~68 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9ba6fdec08044b19bcfcbb3a71db1905dd391283;p=thirdparty%2Flibcgroup.git api: fix coverity warning about uninitialized variable Fix Uninitialized scalar variable, reported by Coverity tool: 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 Signed-off-by: Tom Hromatka --- diff --git a/src/api.c b/src/api.c index 07d16f57..469e2426 100644 --- a/src/api.c +++ b/src/api.c @@ -2611,7 +2611,7 @@ static int _cgroup_create_cgroup(const struct cgroup * const cgroup, const struct cgroup_controller * const controller, 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;