Re: [PATCH v9 3/9] perf config: Collect configs to handle config variables
From: Namhyung Kim
Date: Tue Nov 03 2015 - 07:11:07 EST
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@xxxxxxxxx>
Acked-by: Namhyung Kim <namhyung@xxxxxxxxxx>
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, §ion, &element, section_name, name);
> +
> + if (!section) {
> + section = init_section(section_name);
> + if (!section)
> + goto out_err;
> + list_add_tail(§ion->list, sections);
> + }
> +
> + value = strdup(value);
> + if (!value) {
> + pr_err("%s: strdup failed\n", __func__);
> + goto out_err;
> + }
> +
> + if (!element)
> + add_element(§ion->element_head, name, value);
> + else {
> + free(element->value);
> + element->value = (char *)value;
> + }
> +
> + ret = 0;
> +out_err:
> + free(key);
> + return ret;
> +}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/