lkml.org 
[lkml]   [2015]   [Nov]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v9 3/9] perf config: Collect configs to handle config variables
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;
> +}


\
 
 \ /
  Last update: 2015-11-03 13:21    [W:0.111 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site