Em Wed, Apr 26, 2017 at 09:21:03PM +0900, Taeung Song escreveu: > 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. <SNIP> > +++ 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;
But should we consider an error to have an empty config file? I don't think so :-\ - Arnaldo > > 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