From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752181AbdBAMZV (ORCPT ); Wed, 1 Feb 2017 07:25:21 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:36872 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751389AbdBAMZT (ORCPT ); Wed, 1 Feb 2017 07:25:19 -0500 From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , Adrian Hunter , David Ahern , Jiri Olsa , Namhyung Kim , Taeung Song , Wang Nan Subject: [PATCH 03/14] perf config: Do not consider an error not to have any perfconfig file Date: Wed, 1 Feb 2017 09:24:56 -0300 Message-Id: <20170201122507.29303-4-acme@kernel.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170201122507.29303-1-acme@kernel.org> References: <20170201122507.29303-1-acme@kernel.org> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnaldo Carvalho de Melo While propagating the errors from perf_config(), which were being completely ignored, everything stopped working for people without a ~/.perfconfig file, because the perf_config_set__init() was considering an error not to have a .perfconfig file, duh, fix it by checking the errno after the failed stat() call. It should also not return an error when it says it is ignoring the file, and also a empty file should not return an error either. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Taeung Song Cc: Wang Nan Fixes: 8beeb00f2c84 ("perf config: Use new perf_config_set__init() to initialize config set") Link: http://lkml.kernel.org/n/tip-ygpbab3apbs6l8wr97xedwks@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/config.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c index 3d906dbbef74..615e8b4a693b 100644 --- a/tools/perf/util/config.c +++ b/tools/perf/util/config.c @@ -646,8 +646,13 @@ static int perf_config_set__init(struct perf_config_set *set) goto out; } - if (stat(user_config, &st) < 0) + if (stat(user_config, &st) < 0) { + if (errno == ENOENT) + ret = 0; goto out_free; + } + + ret = 0; if (st.st_uid && (st.st_uid != geteuid())) { warning("File %s not owned by current user or root, " @@ -655,11 +660,8 @@ static int perf_config_set__init(struct perf_config_set *set) goto out_free; } - if (!st.st_size) - goto out_free; - - ret = perf_config_from_file(collect_config, user_config, set); - + if (st.st_size) + ret = perf_config_from_file(collect_config, user_config, set); out_free: free(user_config); } -- 2.9.3