[lttng-dev] [PATCH] Add --list-options to each command

Thibault, Daniel Daniel.Thibault at drdc-rddc.gc.ca
Tue Jan 24 13:05:17 EST 2012


> 5. Re: [PATCH] Add --list-options to each command (Mathieu Desnoyers)
> Date: Tue, 24 Jan 2012 09:44:31 -0500
> From: Mathieu Desnoyers <compudj at krystal.dyndns.org>
>
> If we look at the other options (in other files), 0 (instead of '\0')
> seems to be used as second field. This would keep the style more
> coherent. Can you change this across the whole patch and resubmit ?
>
> e.g. here:
> >  static struct lttng_handle *handle;
> > @@ -70,6 +71,7 @@ static struct poptOption long_options[] = {
> >  	{"num-subbuf",     0,   POPT_ARG_INT, 0, OPT_NUM_SUBBUF, 0, 0},
> >  	{"switch-timer",   0,   POPT_ARG_INT, 0, OPT_SWITCH_TIMER, 0, 0},
> >  	{"read-timer",     0,   POPT_ARG_INT, 0, OPT_READ_TIMER, 0, 0},
> > +	{"list-options",   '\0', POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
> >  	{0, 0, 0, 0, 0, 0, 0}
> >  };
>
> The rest looks fine!

   Actually, since the struct poptOption is defined in popt.h as { const char *longName; char shortName; unsigned int argInfo; void *arg; int val; const char *descrip; const char *argDescrip; }, it would make more sense (and make the compiler happier) to use '/0' for the second member throughout.  For instance, the {0, 0, 0, 0, 0, 0, 0} line should be simply POPT_TABLEEND, which is { NULL, '\0', 0, NULL, 0, NULL, NULL }.

   I'm wondering: why is LTTng 2.0 not using the POPT_AUTOHELP facility of popt's?

Daniel U. Thibault
R & D pour la défense Canada - Valcartier (RDDC Valcartier) / Defence R&D Canada - Valcartier (DRDC Valcartier)
Système de systèmes (SdS) / System of Systems (SoS)
Solutions informatiques et expérimentations (SIE) / Computing Solutions and Experimentations (CSE)
2459 Boul. Pie XI Nord
Québec, QC  G3J 1X5
CANADA
Vox : (418) 844-4000 x4245
Fax : (418) 844-4538
NAC: 918V QSDJ
Gouvernement du Canada / Government of Canada
<http://www.valcartier.drdc-rddc.gc.ca/>



More information about the lttng-dev mailing list