[PATCH 2/7] perf config: Check list empty before showing configs
From: Taeung Song
Date: Wed Apr 26 2017 - 08:22:11 EST
If existent config files contains nothing,
the sections list in config_set can be empty.
So check not only NULL pointer of config_set but
also the list in config_set.
Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
Signed-off-by: Taeung Song <treeze.taeung@xxxxxxxxx>
---
tools/perf/builtin-config.c | 4 ++--
tools/perf/util/config.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index 80668fa..9ec8664 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -75,7 +75,7 @@ static int show_spec_config(struct perf_config_set *set, const char *var)
struct perf_config_section *section;
struct perf_config_item *item;
- if (set == NULL)
+ if (set == NULL || list_empty(&set->sections))
return -1;
perf_config_items__for_each_entry(&set->sections, section) {
@@ -105,7 +105,7 @@ static int show_config(struct perf_config_set *set)
struct perf_config_section *section;
struct perf_config_item *item;
- if (set == NULL)
+ if (set == NULL || list_empty(&set->sections))
return -1;
perf_config_set__for_each_entry(set, section, item) {
diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
index 8d724f0..492c862 100644
--- a/tools/perf/util/config.c
+++ b/tools/perf/util/config.c
@@ -707,7 +707,7 @@ int perf_config(config_fn_t fn, void *data)
struct perf_config_section *section;
struct perf_config_item *item;
- if (config_set == NULL)
+ if (config_set == NULL || list_empty(&config_set->sections))
return -1;
perf_config_set__for_each_entry(config_set, section, item) {
--
2.7.4