Messages in this thread | | | Date | Sun, 9 Aug 2015 12:07:50 +0900 | From | Namhyung Kim <> | Subject | Re: [PATCH v4 4/5] perf config: Add a option 'list-all' to perf-config |
| |
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
| |