lkml.org 
[lkml]   [2017]   [May]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH 2/7] perf config: Check list empty before showing configs
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

\
 
 \ /
  Last update: 2017-05-02 17:13    [W:0.061 / U:2.208 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site