public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Taeung Song <treeze.taeung@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	linux-kernel@vger.kernel.org, jolsa@redhat.com,
	Ingo Molnar <mingo@redhat.com>
Subject: Re: [PATCH v9 3/9] perf config: Collect configs to handle config variables
Date: Tue, 3 Nov 2015 21:10:50 +0900	[thread overview]
Message-ID: <20151103121050.GF5733@danjae.kornet> (raw)
In-Reply-To: <1446515420-22681-4-git-send-email-treeze.taeung@gmail.com>

On Tue, Nov 03, 2015 at 10:50:14AM +0900, Taeung Song wrote:
> Collecting configs into list because of two reason.
> 
> First of all, if there are same variables both user
> and system config file, they all will be printed
> when 'list' command work. But if config variables are
> duplicated, user config variables should only be printed
> because it has priority.
> 
> Lastly, list into which configs is collected
> will be required to keep and handle config variables
> and values in the near furture. For example,
> getting or setting functionality.
> 
> And change show_config() function.
> Old show_config() worked depending on perf_config().
> New show_config() work using collected configs list.
> 
> Signed-off-by: Taeung Song <treeze.taeung@gmail.com>

Acked-by: Namhyung Kim <namhyung@kernel.org>

One nitpick again..


[SNIP]
> +static int collect_current_config(const char *var, const char *value,
> +				  void *spec_sections __maybe_unused)

The spec_sections is actually used, so "__maybe_unused" is not necessary.

Thanks,
Namhyung


> +{
> +	int ret = -1;
> +	char *ptr, *key;
> +	char *section_name, *name;
> +	struct config_section *section = NULL;
> +	struct config_element *element = NULL;
> +	struct list_head *sections = (struct list_head *)spec_sections;
> +
> +	key = ptr = strdup(var);
> +	if (!key) {
> +		pr_err("%s: strdup failed\n", __func__);
> +		return -1;
> +	}
> +
> +	section_name = strsep(&ptr, ".");
> +	name = ptr;
> +	if (name == NULL || value == NULL)
> +		goto out_err;
> +
> +	find_config(sections, &section, &element, section_name, name);
> +
> +	if (!section) {
> +		section = init_section(section_name);
> +		if (!section)
> +			goto out_err;
> +		list_add_tail(&section->list, sections);
> +	}
> +
> +	value = strdup(value);
> +	if (!value) {
> +		pr_err("%s: strdup failed\n", __func__);
> +		goto out_err;
> +	}
> +
> +	if (!element)
> +		add_element(&section->element_head, name, value);
> +	else {
> +		free(element->value);
> +		element->value = (char *)value;
> +	}
> +
> +	ret = 0;
> +out_err:
> +	free(key);
> +	return ret;
> +}

  reply	other threads:[~2015-11-03 12:11 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-03  1:50 [PATCH v9 0/9] perf tools: Add 'perf-config' command Taeung Song
2015-11-03  1:50 ` [PATCH v9 1/9] " Taeung Song
2015-11-03 11:36   ` Namhyung Kim
2015-11-03 15:40   ` Arnaldo Carvalho de Melo
2015-11-05 10:19     ` Taeung Song
2015-11-03  1:50 ` [PATCH v9 2/9] perf config: Add '--system' and '--user' options to select which config file is used Taeung Song
2015-11-03 11:49   ` Namhyung Kim
2015-11-03  1:50 ` [PATCH v9 3/9] perf config: Collect configs to handle config variables Taeung Song
2015-11-03 12:10   ` Namhyung Kim [this message]
2015-11-03  1:50 ` [PATCH v9 4/9] perf config: Add comparing name treating '_' and '-' as being the same thing Taeung Song
2015-11-03 12:15   ` Namhyung Kim
2015-11-03  1:50 ` [PATCH v9 5/9] perf config: Add a option 'list-all' to perf-config Taeung Song
2015-11-03 12:29   ` Namhyung Kim
2015-11-03  1:50 ` [PATCH v9 6/9] perf config: Add 'get' functionaliy Taeung Song
2015-11-03  1:50 ` [PATCH v9 7/9] perf config: Add 'set' feature Taeung Song
2015-11-03  1:50 ` [PATCH v9 8/9] perf config: normalize a value depending on default type of it Taeung Song
2015-11-03  1:50 ` [PATCH v9 9/9] perf config: Add a option 'remove' to perf-config 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=20151103121050.GF5733@danjae.kornet \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox