From 2d8846d37f32c0a787d5c59c01db9df3b4da246b Mon Sep 17 00:00:00 2001 From: Kamalesh Babulal Date: Mon, 31 Mar 2025 19:41:12 +0530 Subject: [PATCH] tools/cgsnapshot: Fix Coverity uninitialized variable warning Coverity reported the following uninitialized variable warning: CID 465887: (#1 of 1): Uninitialized scalar variable (UNINIT) 32. uninit_use_in_call: Using uninitialized value *wl_file when calling load_list. Fix the issue by initializing the char[] wl_file with '\0', and also initialize dl_file similarly as a best practice. Signed-off-by: Kamalesh Babulal Signed-off-by: Tom Hromatka --- src/tools/cgsnapshot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tools/cgsnapshot.c b/src/tools/cgsnapshot.c index d77be0dd..95ca3960 100644 --- a/src/tools/cgsnapshot.c +++ b/src/tools/cgsnapshot.c @@ -743,8 +743,8 @@ int main(int argc, char *argv[]) }; cont_name_t wanted_cont[CG_CONTROLLER_MAX]; - char bl_file[FILENAME_MAX]; /* denylist file name */ - char wl_file[FILENAME_MAX]; /* allowlist file name */ + char bl_file[FILENAME_MAX] = { "\0" }; /* denylist file name */ + char wl_file[FILENAME_MAX] = { "\0" }; /* allowlist file name */ int ret = 0, err; int c_number = 0; int c, i; -- 2.47.3