|
|
b12e4c |
From 99d045d33f9805d7f81012d2bf7f01edcddb97f2 Mon Sep 17 00:00:00 2001
|
|
|
b12e4c |
From: Ernestas Kulik <ekulik@redhat.com>
|
|
|
b12e4c |
Date: Tue, 4 Jun 2019 15:46:20 +0200
|
|
|
b12e4c |
Subject: [PATCH] lib: problem_data: Use g_strsplit()
|
|
|
b12e4c |
|
|
|
b12e4c |
Our own implementation is rather opaque and is causing Coverity to yell.
|
|
|
b12e4c |
|
|
|
b12e4c |
Signed-off-by: Ernestas Kulik <ekulik@redhat.com>
|
|
|
b12e4c |
---
|
|
|
b12e4c |
src/lib/problem_data.c | 44 ++----------------------------------------
|
|
|
b12e4c |
1 file changed, 2 insertions(+), 42 deletions(-)
|
|
|
b12e4c |
|
|
|
b12e4c |
diff --git a/src/lib/problem_data.c b/src/lib/problem_data.c
|
|
|
b12e4c |
index 2f66fb3..fdecc83 100644
|
|
|
b12e4c |
--- a/src/lib/problem_data.c
|
|
|
b12e4c |
+++ b/src/lib/problem_data.c
|
|
|
b12e4c |
@@ -519,56 +519,16 @@ problem_data_t *create_problem_data_from_dump_dir(struct dump_dir *dd)
|
|
|
b12e4c |
return problem_data;
|
|
|
b12e4c |
}
|
|
|
b12e4c |
|
|
|
b12e4c |
-/*
|
|
|
b12e4c |
- * Returns NULL-terminated char *vector[]. Result itself must be freed,
|
|
|
b12e4c |
- * but do no free list elements. IOW: do free(result), but never free(result[i])!
|
|
|
b12e4c |
- * If comma_separated_list is NULL or "", returns NULL.
|
|
|
b12e4c |
- */
|
|
|
b12e4c |
-static char **build_exclude_vector(const char *comma_separated_list)
|
|
|
b12e4c |
-{
|
|
|
b12e4c |
- char **exclude_items = NULL;
|
|
|
b12e4c |
- if (comma_separated_list && comma_separated_list[0])
|
|
|
b12e4c |
- {
|
|
|
b12e4c |
- /* even w/o commas, we'll need two elements:
|
|
|
b12e4c |
- * exclude_items[0] = "name"
|
|
|
b12e4c |
- * exclude_items[1] = NULL
|
|
|
b12e4c |
- */
|
|
|
b12e4c |
- unsigned cnt = 2;
|
|
|
b12e4c |
-
|
|
|
b12e4c |
- const char *cp = comma_separated_list;
|
|
|
b12e4c |
- while (*cp)
|
|
|
b12e4c |
- if (*cp++ == ',')
|
|
|
b12e4c |
- cnt++;
|
|
|
b12e4c |
-
|
|
|
b12e4c |
- /* We place the string directly after the char *vector[cnt]: */
|
|
|
b12e4c |
- exclude_items = xzalloc(cnt * sizeof(exclude_items[0]) + (cp - comma_separated_list) + 1);
|
|
|
b12e4c |
- char *p = strcpy((char*)&exclude_items[cnt], comma_separated_list);
|
|
|
b12e4c |
-
|
|
|
b12e4c |
- char **pp = exclude_items;
|
|
|
b12e4c |
- *pp++ = p;
|
|
|
b12e4c |
- while (*p)
|
|
|
b12e4c |
- {
|
|
|
b12e4c |
- if (*p++ == ',')
|
|
|
b12e4c |
- {
|
|
|
b12e4c |
- p[-1] = '\0';
|
|
|
b12e4c |
- *pp++ = p;
|
|
|
b12e4c |
- }
|
|
|
b12e4c |
- }
|
|
|
b12e4c |
- }
|
|
|
b12e4c |
-
|
|
|
b12e4c |
- return exclude_items;
|
|
|
b12e4c |
-}
|
|
|
b12e4c |
-
|
|
|
b12e4c |
problem_data_t *create_problem_data_for_reporting(const char *dump_dir_name)
|
|
|
b12e4c |
{
|
|
|
b12e4c |
struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
|
|
|
b12e4c |
if (!dd)
|
|
|
b12e4c |
return NULL; /* dd_opendir already emitted error msg */
|
|
|
b12e4c |
- char **exclude_items = build_exclude_vector(getenv("EXCLUDE_FROM_REPORT"));
|
|
|
b12e4c |
+ char **exclude_items = g_strsplit(getenv("EXCLUDE_FROM_REPORT"), ",", -1);
|
|
|
b12e4c |
problem_data_t *problem_data = problem_data_new();
|
|
|
b12e4c |
problem_data_load_from_dump_dir(problem_data, dd, exclude_items);
|
|
|
b12e4c |
dd_close(dd);
|
|
|
b12e4c |
- free(exclude_items);
|
|
|
b12e4c |
+ g_strfreev(exclude_items);
|
|
|
b12e4c |
return problem_data;
|
|
|
b12e4c |
}
|
|
|
b12e4c |
|
|
|
b12e4c |
--
|
|
|
b12e4c |
2.21.0
|
|
|
b12e4c |
|