From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753881AbbKCMLE (ORCPT ); Tue, 3 Nov 2015 07:11:04 -0500 Received: from mail-pa0-f54.google.com ([209.85.220.54]:34118 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751288AbbKCMLB (ORCPT ); Tue, 3 Nov 2015 07:11:01 -0500 Date: Tue, 3 Nov 2015 21:10:50 +0900 From: Namhyung Kim To: Taeung Song Cc: Arnaldo Carvalho de Melo , linux-kernel@vger.kernel.org, jolsa@redhat.com, Ingo Molnar Subject: Re: [PATCH v9 3/9] perf config: Collect configs to handle config variables Message-ID: <20151103121050.GF5733@danjae.kornet> References: <1446515420-22681-1-git-send-email-treeze.taeung@gmail.com> <1446515420-22681-4-git-send-email-treeze.taeung@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1446515420-22681-4-git-send-email-treeze.taeung@gmail.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Acked-by: Namhyung Kim 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; > +}