From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751461AbdECEFr (ORCPT ); Wed, 3 May 2017 00:05:47 -0400 Received: from mail-pg0-f48.google.com ([74.125.83.48]:35740 "EHLO mail-pg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750981AbdECEFk (ORCPT ); Wed, 3 May 2017 00:05:40 -0400 Subject: Re: [PATCH 2/7] perf config: Check list empty before showing configs To: Arnaldo Carvalho de Melo References: <1493209268-5543-1-git-send-email-treeze.taeung@gmail.com> <1493209268-5543-3-git-send-email-treeze.taeung@gmail.com> <20170502151200.GA7891@kernel.org> Cc: linux-kernel@vger.kernel.org, Jiri Olsa , Namhyung Kim From: Taeung Song Message-ID: Date: Wed, 3 May 2017 13:05:35 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170502151200.GA7891@kernel.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Arnaldo, On 05/03/2017 12:12 AM, Arnaldo Carvalho de Melo wrote: > Em Wed, Apr 26, 2017 at 09:21:03PM +0900, Taeung Song escreveu: >> 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. > >> +++ 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; > > But should we consider an error to have an empty config file? I don't > think so :-\ > > - Arnaldo I think if we do, when a config file is not only not exist but also empty, user can see the error message (e.g. "Nothing configured, please check your ~/.perfconfig"). And IMHO, it seems better. But if you don't think so, I got it. Thanks, Taeung