Re: [PATCH 2/7] perf config: Check list empty before showing configs

From: Taeung Song
Date: Wed May 03 2017 - 00:05:57 EST


Hi Arnaldo,

On 05/03/2017 12:12 AM, Arnaldo Carvalho de Melo wrote:
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

I think if we do, when a config file is not only not exist but also empty,
user can see the error message
(e.g. "Nothing configured, please check your ~/.perfconfig").
And IMHO, it seems better.

But if you don't think so, I got it.

Thanks,
Taeung