All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Taeung Song <treeze.taeung@gmail.com>
Cc: linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>
Subject: Re: [PATCH 2/7] perf config: Check list empty before showing configs
Date: Tue, 2 May 2017 12:12:00 -0300	[thread overview]
Message-ID: <20170502151200.GA7891@kernel.org> (raw)
In-Reply-To: <1493209268-5543-3-git-send-email-treeze.taeung@gmail.com>

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

  reply	other threads:[~2017-05-02 15:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-26 12:21 [PATCH 0/7] perf config: Bugfixes & Refactoring Taeung Song
2017-04-26 12:21 ` [PATCH 1/7] perf config: Refactor a duplicated code for config file name Taeung Song
2017-05-03 17:38   ` [tip:perf/urgent] perf config: Refactor a duplicated code for obtaining " tip-bot for Taeung Song
2017-04-26 12:21 ` [PATCH 2/7] perf config: Check list empty before showing configs Taeung Song
2017-05-02 15:12   ` Arnaldo Carvalho de Melo [this message]
2017-05-03  4:05     ` Taeung Song
2017-04-26 12:21 ` [PATCH 3/7] perf config: Use none_err for all cases that nothing configured Taeung Song
2017-04-26 12:21 ` [PATCH 4/7] perf config: Invert if statements to reduce nesting in cmd_config() Taeung Song
2017-04-26 12:21 ` [PATCH 5/7] perf config: Correctly check whether it is from system config Taeung Song
2017-04-26 12:21 ` [PATCH 6/7] perf config: Finally write changed configs on config file at a time Taeung Song
2017-04-26 12:21 ` [PATCH 7/7] perf config: No free config set when it's initialization failed Taeung Song

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170502151200.GA7891@kernel.org \
    --to=acme@kernel.org \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namhyung@kernel.org \
    --cc=treeze.taeung@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.