Linux Trace Kernel
 help / color / mirror / Atom feed
From: Wander Lairson Costa <wander@redhat.com>
To: Tomas Glozar <tglozar@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	John Kacur <jkacur@redhat.com>,
	 Luis Goncalves <lgoncalv@redhat.com>,
	Crystal Wood <crwood@redhat.com>,
	 Costa Shulyupin <costa.shul@redhat.com>,
	LKML <linux-kernel@vger.kernel.org>,
	 linux-trace-kernel <linux-trace-kernel@vger.kernel.org>
Subject: Re: [PATCH] rtla/cli: Unify and improve handling of invalid option arguments
Date: Thu, 16 Jul 2026 13:20:53 -0300	[thread overview]
Message-ID: <alkE1Ga091Qar4DS@wcosta-defaultstring.rmtbr.csb> (raw)
In-Reply-To: <20260716144901.1187474-1-tglozar@redhat.com>

On Thu, Jul 16, 2026 at 04:49:01PM +0200, Tomas Glozar wrote:
> The current handling of invalid command line option arguments is
> inconsistent:
> 
> - opt_llong_callback() treats non-numerical input the same as "-1",
>   which might or might not be rejected later.
> - opt_int_callback() returns -1 on non-numerical input without an error
>   message, which makes parsing fail silently (libsubcmd will
>   automatically print the usage of the option only, no error message).
> - custom callbacks abort command line parsing using fatal(), which
>   displays an error message and exits, without libsubcmd printing the
>   usage.
> 
> Unify this such that all invalid options, regardless of the format,
> print an error message similar to the out of range case:
> 
> Error: --opt: 'value' is not a valid XY
> 
> followed by the usage of the option, e.g.:
> 
> $ rtla timerlat hist --period=1us
>  Error: --period: '1us' is not a valid number
> 
>  Usage: rtla timerlat hist [<options>] [-h|--help]
> 
>     -p, --period <us>     timerlat period in us
> 
> As this is a libsubcmd help path, all option parsing failures now return
> the exit code of 129 (help).
> 
> The unified handling is implemented using a new error message helper,
> opt_err(), which is called from two new CLI-specific parsing functions,
> strtoll_safe() and strtoi_safe(), as well as from custom helpers.
> 
> Option callback tests are updated to cover the new behavior.
> 
> Assisted-by: Claude:claude-opus-4-6
> Signed-off-by: Tomas Glozar <tglozar@redhat.com>

Reviewed-by: Wander Lairson Costa <wander@redhat.com>


      reply	other threads:[~2026-07-16 16:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-16 14:49 [PATCH] rtla/cli: Unify and improve handling of invalid option arguments Tomas Glozar
2026-07-16 16:20 ` Wander Lairson Costa [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alkE1Ga091Qar4DS@wcosta-defaultstring.rmtbr.csb \
    --to=wander@redhat.com \
    --cc=costa.shul@redhat.com \
    --cc=crwood@redhat.com \
    --cc=jkacur@redhat.com \
    --cc=lgoncalv@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tglozar@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox