Re: [PATCH 1/4] rtla: Allow unsetting non-list custom-callback CLI options

Wander Lairson Costa <[email protected]>
Newsgroups org.kernel.vger.linux-trace-kernel,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On Mon, Jun 29, 2026 at 10:36:51AM +0200, Tomas Glozar wrote:
> libsubcmd implicitly allows the user to unset already set options using
> a "no-" prefix for long options. For example, if I set the period like
> this:
> 
> $ rtla timerlat -D
> Loading BPF program
> reading osnoise/timerlat_period_us returned 1000
> setting osnoise/timerlat_period_us to 1000
> reading osnoise/print_stack returned 0
> setting osnoise/print_stack to 0
> ...
> <timerlat top>
> 
> it can be unset by a subsequent --no-debug:
> 
> $ rtla timerlat -D --no-debug
> ...
> <timerlat top>
> 
> Currently, this works only for boolean options. Extend the feature for
> all options by implementing handling of the "unset" argument in opt_*()
> callbacks defined in cli_p.h, except for list options, i.e. options that
> can be passed multiple times (--event, --filter, --trigger,
> --on-threshold, --on-end).
> 
> This allows, for example, unsetting of int/long long options, e.g. "-p":
> 
> $ rtla timerlat -D -p100 --no-period
> ...
> setting osnoise/timerlat_period_us to 1000
> ...
> 
> By default, options in params struct are reset to zero. A constant is
> added for every parameter with a different default value, which is then
> used both in <tool>_hist_args() while setting the initial value and in
> opt_*() when unsetting the option. This refactoring ensures there is no
> duplicate "magic number".
> 
> The default value for opt_llong_callback() and opt_int_callback() is
> passed in struct option's defval field; new macros
> RTLA_OPT_{LLONG,INT}{,_DEFVAL} are added to define the field
> conveniently. The default value for other callbacks is hardcoded inside
> each callback's unset logic.
> 
> Signed-off-by: Tomas Glozar <[email protected]>

Reviewed-by: Wander Lairson Costa <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.