[lttng-dev] [PATCH] disable_channels.c improvements and fixes

Thibault, Daniel Daniel.Thibault at drdc-rddc.gc.ca
Wed Feb 1 13:30:47 EST 2012

> >  	/* Strip channel list */
> >  	channel_name = strtok(opt_channels, ",");
> > +	/* Default to a warning in case opt_channels is empty */
> > +	ret = CMD_WARNING;
> Actually, at this point, opt_channels *can not* be empty. There is a check
> before calling this function.
> So, if ret is cmd_success by default, only warn==1 will be enough after this
> loop. Am I missing something ?

   Wrong.  opt_channels cannot be NULL, but it can effectively be empty.  Consider this case: 'lttng disable-channel ,,,'.  cmd_disable_channels()'s poptGetArg() will return ",,," (not NULL).  The first strtok() in disable_channels() call will return NULL straight away, and we'll skip right over the while.  Hence the default ret value.

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
Vox : (418) 844-4000 x4245
Fax : (418) 844-4538
Gouvernement du Canada / Government of Canada

More information about the lttng-dev mailing list