From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754225AbbHIDKe (ORCPT ); Sat, 8 Aug 2015 23:10:34 -0400 Received: from mail-pd0-f171.google.com ([209.85.192.171]:34431 "EHLO mail-pd0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751928AbbHIDKb (ORCPT ); Sat, 8 Aug 2015 23:10:31 -0400 Date: Sun, 9 Aug 2015 12:07:50 +0900 From: Namhyung Kim To: Taewoong Song Cc: Arnaldo Carvalho de Melo , "linux-kernel@vger.kernel.org" , jolsa@redhat.com, Ingo Molnar Subject: Re: [PATCH v4 4/5] perf config: Add a option 'list-all' to perf-config Message-ID: <20150809030750.GC29295@danjae.kornet> References: <1437926311-16226-1-git-send-email-treeze.taeung@gmail.com> <1437926311-16226-5-git-send-email-treeze.taeung@gmail.com> <20150727084847.GD22022@danjae.kornet> <55C405E2.3060908@gmail.com> <9C7D1EDC-754E-4B4A-8986-8435BF5B343E@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <9C7D1EDC-754E-4B4A-8986-8435BF5B343E@gmail.com> User-Agent: Mutt/1.5.23+102 (2ca89bed6448) (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Aug 08, 2015 at 06:50:59PM +0900, Taewoong Song wrote: > >>> OPT_GROUP("Action"), > >>> OPT_BIT('l', "list", &actions, > >>> "show current config variables", ACTION_LIST), > >>> + OPT_BIT('a', "list-all", &actions, > >>> + "show current and all possible config variables with default values", ACTION_LIST_ALL), > >> Why did you use OPT_BIT? Do you want to support multiple 'actions' at > >> the same time? I'd rather support just one action, but I won't insist > >> it strongly.. Anyway, setting bits will confuse the switch statement > >> in the cmd_config(). > >> > >> Thanks, > >> Namhyung > >> > > I don't understand why setting bits will confuse the switch statement. > > Is the reason about readability of source code ? > > > > But I searched for other parse-option which can be replaced. > > Is it better to use OPT_SET_INT instead of OPT_BIT ? > > > > I modified source code to use OPT_SET_UINT > but the problem is happened. I declared "enum actions” to use OPT_SET_UINT like this. > > enum actions { > ACTION_LIST, > ACTION_LIST_ALL, > ACTION_REMOVE > } actions; > > But default value of actions” variable is 0 and ACTION_LIST is also 0 > so when ‘get’ or ’set’ feature is used, ‘default:' of the switch statement in cmd_config() can’t reached > because of default value of ‘actions’ variable is 0. I don't know what's the problem. You could either set default value to -1 or make ACTION_LIST start from 1. Thanks, Namhyung