Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2999749AbdDZMW1 (ORCPT ); Wed, 26 Apr 2017 08:22:27 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:36677 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2999699AbdDZMVk (ORCPT ); Wed, 26 Apr 2017 08:21:40 -0400 From: Taeung Song To: Arnaldo Carvalho de Melo Cc: linux-kernel@vger.kernel.org, Jiri Olsa , Namhyung Kim , Taeung Song Subject: [PATCH 3/7] perf config: Use none_err for all cases that nothing configured Date: Wed, 26 Apr 2017 21:21:04 +0900 Message-Id: <1493209268-5543-4-git-send-email-treeze.taeung@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493209268-5543-1-git-send-email-treeze.taeung@gmail.com> References: <1493209268-5543-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 Content-Length: 2028 Lines: 78 Currently there's only one error message for nothing configured. Before: $ perf config -l Nothing configured, please check your /home/taeung/.perfconfig $ perf config report.queue-size So use none_err to handle all cases when nothing configured, and also use it instead of out_err that skip the error message. After: $ perf config -l Nothing configured, please check your /home/taeung/.perfconfig $ perf config report.queue-size Nothing configured, please check your /home/taeung/.perfconfig Cc: Jiri Olsa Cc: Namhyung Kim Signed-off-by: Taeung Song --- tools/perf/builtin-config.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c index 9ec8664..ad0a112 100644 --- a/tools/perf/builtin-config.c +++ b/tools/perf/builtin-config.c @@ -188,7 +188,7 @@ int cmd_config(int argc, const char **argv) set = perf_config_set__new(); if (!set) { ret = -1; - goto out_err; + goto none_err; } switch (actions) { @@ -199,8 +199,7 @@ int cmd_config(int argc, const char **argv) } else { ret = show_config(set); if (ret < 0) - pr_err("Nothing configured, " - "please check your %s \n", config_filename); + goto none_err; } break; default: @@ -221,9 +220,11 @@ int cmd_config(int argc, const char **argv) break; } - if (value == NULL) + if (value == NULL) { ret = show_spec_config(set, var); - else + if (ret < 0) + goto none_err; + } else ret = set_config(set, config_filename, var, value); free(arg); } @@ -231,7 +232,11 @@ int cmd_config(int argc, const char **argv) usage_with_options(config_usage, config_options); } +none_err: + if (ret < 0 && (!set || list_empty(&set->sections))) + pr_err("Nothing configured, " + "please check your %s \n", config_filename); + perf_config_set__delete(set); -out_err: return ret; } -- 2.7.4