Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2999738AbdDZMWH (ORCPT ); Wed, 26 Apr 2017 08:22:07 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:32803 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2999696AbdDZMVi (ORCPT ); Wed, 26 Apr 2017 08:21:38 -0400 From: Taeung Song To: Arnaldo Carvalho de Melo Cc: linux-kernel@vger.kernel.org, Jiri Olsa , Namhyung Kim , Taeung Song Subject: [PATCH 2/7] perf config: Check list empty before showing configs Date: Wed, 26 Apr 2017 21:21:03 +0900 Message-Id: <1493209268-5543-3-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: 1664 Lines: 51 If existent config files contains nothing, the sections list in config_set can be empty. So check not only NULL pointer of config_set but also the list in config_set. Cc: Jiri Olsa Cc: Namhyung Kim Signed-off-by: Taeung Song --- tools/perf/builtin-config.c | 4 ++-- tools/perf/util/config.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c index 80668fa..9ec8664 100644 --- a/tools/perf/builtin-config.c +++ b/tools/perf/builtin-config.c @@ -75,7 +75,7 @@ static int show_spec_config(struct perf_config_set *set, const char *var) struct perf_config_section *section; struct perf_config_item *item; - if (set == NULL) + if (set == NULL || list_empty(&set->sections)) return -1; perf_config_items__for_each_entry(&set->sections, section) { @@ -105,7 +105,7 @@ static int show_config(struct perf_config_set *set) struct perf_config_section *section; struct perf_config_item *item; - if (set == NULL) + if (set == NULL || list_empty(&set->sections)) return -1; perf_config_set__for_each_entry(set, section, item) { diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c index 8d724f0..492c862 100644 --- a/tools/perf/util/config.c +++ b/tools/perf/util/config.c @@ -707,7 +707,7 @@ int perf_config(config_fn_t fn, void *data) struct perf_config_section *section; struct perf_config_item *item; - if (config_set == NULL) + if (config_set == NULL || list_empty(&config_set->sections)) return -1; perf_config_set__for_each_entry(config_set, section, item) { -- 2.7.4