From 98ac2456e3e5a4fcee232e34bfb78c8156d7c035 Mon Sep 17 00:00:00 2001 From: "xiang.zhou" Date: Tue, 5 Sep 2023 09:56:08 +0800 Subject: [PATCH] fixbug:log file name filtering error --- src/utils/log.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/utils/log.c b/src/utils/log.c index e4a1c6f7..19b52d9c 100644 --- a/src/utils/log.c +++ b/src/utils/log.c @@ -27,11 +27,10 @@ static UT_array *collect_logs(const char *dir, const char *node) { - DIR * dirp = NULL; - struct dirent *dent = NULL; - UT_array * files = NULL; - char flag[NEU_NODE_NAME_LEN + 2] = { 0 }; - char flag_[NEU_NODE_NAME_LEN + 2] = { 0 }; + DIR * dirp = NULL; + struct dirent *dent = NULL; + UT_array * files = NULL; + char flag[NEU_NODE_NAME_LEN + 2] = { 0 }; if ((dirp = opendir(dir)) == NULL) { nlog_error("fail open dir: %s", dir); @@ -40,11 +39,9 @@ static UT_array *collect_logs(const char *dir, const char *node) utarray_new(files, &ut_str_icd); snprintf(flag, sizeof(flag), "%s.", node); - snprintf(flag_, sizeof(flag_), "%s_", node); while (NULL != (dent = readdir(dirp))) { - if (strstr(dent->d_name, flag) != NULL || - strstr(dent->d_name, flag_) != NULL) { + if (strstr(dent->d_name, flag) != NULL) { char *file = dent->d_name; utarray_push_back(files, &file); }