From 0bac094e2ac018cb40d6e8d666b9feacc08bb0d4 Mon Sep 17 00:00:00 2001 From: Tanuj Tekriwal Date: Thu, 5 Sep 2024 07:52:06 +0000 Subject: [PATCH] Fix for Coverity issues for crashlog This patch fixes few coverity issues for log_capture Tests Done: Build and boot Tracked-On: OAM-124424 Signed-off-by: Tanuj Tekriwal --- crashlog/crashutils.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crashlog/crashutils.c b/crashlog/crashutils.c index 4c225ba..d7be121 100755 --- a/crashlog/crashutils.c +++ b/crashlog/crashutils.c @@ -162,7 +162,7 @@ unsigned long long get_uptime(int refresh, int *error) } // Find system last kmsg from dropbox -static int find_system_last_kmsg(char source[], int source_length) { +static int find_system_last_kmsg(char *source, int source_length) { struct dirent *entry; DIR *dir = opendir(DROPBOX_DIR); int file_exist = 0; @@ -183,6 +183,7 @@ static int find_system_last_kmsg(char source[], int source_length) { } } } + closedir(dir); return file_exist; } @@ -205,7 +206,7 @@ void do_last_kmsg_copy(char *dir) { snprintf(destion, sizeof(destion), "%s/%s", dir, FTRACE_RAMOOPS_FILE); do_copy_tail(FTRACE_RAMOOPS, destion, MAXFILESIZE); } - if (find_system_last_kmsg(source, sizeof(source))) { + if (find_system_last_kmsg(&source, sizeof(source))) { snprintf(destion, sizeof(destion), "%s/%s", dir, source); snprintf(sourcepath, sizeof(sourcepath), "%s/%s", DROPBOX_DIR, source); do_copy_tail(sourcepath, destion, MAXFILESIZE);