From aeef26440d22a13e48206cec494f97a04e82b1f8 Mon Sep 17 00:00:00 2001 From: Tom Hromatka Date: Tue, 29 Jul 2025 16:17:13 +0000 Subject: [PATCH] cgxget: Fix clang warning Fix the following clang warning by explicitily initializing disk_cg to NULL. tools/cgxget.c:903:6: warning: variable 'disk_cg' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] 903 | if (!cg || !(*cg)) { | ^~~~~~~~~~~~~ tools/cgxget.c:940:6: note: uninitialized use occurs here 940 | if (disk_cg) | ^~~~~~~ tools/cgxget.c:903:2: note: remove the 'if' if its condition is always false 903 | if (!cg || !(*cg)) { | ^~~~~~~~~~~~~~~~~~~~ 904 | ret = ECGINVAL; | ~~~~~~~~~~~~~~~ 905 | goto out; | ~~~~~~~~~ 906 | } | ~ Signed-off-by: Tom Hromatka Signed-off-by: Kamalesh Babulal --- src/tools/cgxget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/cgxget.c b/src/tools/cgxget.c index ef69a8a2..4192de59 100644 --- a/src/tools/cgxget.c +++ b/src/tools/cgxget.c @@ -897,7 +897,7 @@ err: #ifdef LIBCG_LIB int cgroup_cgxget(struct cgroup **cg, enum cg_version_t version, bool ignore_unmappable) { - struct cgroup *disk_cg, *out_cg; + struct cgroup *disk_cg = NULL, *out_cg; int ret; if (!cg || !(*cg)) { -- 2.47.2