summaryrefslogtreecommitdiff
path: root/tools/perf/scripts/python/stackcollapse.py
diff options
context:
space:
mode:
authorTomas Glozar <tglozar@redhat.com>2026-07-16 16:49:01 +0200
committerTomas Glozar <tglozar@redhat.com>2026-08-05 10:14:40 +0200
commit0ad45018ace734e3a21c8b15280df65b429135d1 (patch)
treeb42a334afb2622a22cada678cc8e908c3b8b8bc3 /tools/perf/scripts/python/stackcollapse.py
parent92a33d5bad7485b39c7403ad1741b3b2b35a0131 (diff)
rtla/cli: Unify and improve handling of invalid option arguments
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 Reviewed-by: Wander Lairson Costa <wander@redhat.com> Link: https://lore.kernel.org/r/20260716144901.1187474-1-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
Diffstat (limited to 'tools/perf/scripts/python/stackcollapse.py')
0 files changed, 0 insertions, 0 deletions