From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932431AbcFGJ0t (ORCPT ); Tue, 7 Jun 2016 05:26:49 -0400 Received: from mail-pa0-f68.google.com ([209.85.220.68]:33903 "EHLO mail-pa0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932284AbcFGJ0p (ORCPT ); Tue, 7 Jun 2016 05:26:45 -0400 From: Taeung Song To: Arnaldo Carvalho de Melo Cc: linux-kernel@vger.kernel.org, Jiri Olsa , Namhyung Kim , Ingo Molnar , Peter Zijlstra , Alexander Shishkin , Masami Hiramatsu , Taeung Song , Jiri Olsa Subject: [PATCH v7 7/7] perf config: Reimplement show_config() using perf_config() Date: Tue, 7 Jun 2016 18:26:17 +0900 Message-Id: <1465291577-20973-8-git-send-email-treeze.taeung@gmail.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1465291577-20973-1-git-send-email-treeze.taeung@gmail.com> References: <1465291577-20973-1-git-send-email-treeze.taeung@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Old show_config() directly use config set so there are many duplicated code with perf_config_set__iter(). So reimplement show_config() using perf_config() that use perf_config_set__iter() with config set that already contains all configs. Cc: Namhyung Kim Cc: Jiri Olsa Cc: Masami Hiramatsu Cc: Alexander Shishkin Signed-off-by: Taeung Song --- tools/perf/builtin-config.c | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c index 4dab41e..b6ae8ea 100644 --- a/tools/perf/builtin-config.c +++ b/tools/perf/builtin-config.c @@ -33,28 +33,13 @@ static struct option config_options[] = { OPT_END() }; -static int show_config(struct perf_config_set *set) +static int show_config(const char *key, const char *value, + void *cb __maybe_unused) { - struct perf_config_section *section; - struct perf_config_item *item; - struct list_head *sections; - - if (set == NULL) - return -1; - - sections = &set->sections; - if (list_empty(sections)) - return -1; - - list_for_each_entry(section, sections, node) { - list_for_each_entry(item, §ion->items, node) { - char *value = item->value; - - if (value) - printf("%s.%s=%s\n", section->name, - item->name, value); - } - } + if (value) + printf("%s=%s\n", key, value); + else + printf("%s\n", key); return 0; } @@ -96,7 +81,7 @@ int cmd_config(int argc, const char **argv, const char *prefix __maybe_unused) pr_err("Error: takes no arguments\n"); parse_options_usage(config_usage, config_options, "l", 1); } else { - ret = show_config(config_set); + ret = perf_config(show_config, NULL); if (ret < 0) { const char * config_filename = config_exclusive_filename; if (!config_exclusive_filename) -- 2.5.0