| 0ad45018 | 16-Jul-2026 |
Tomas Glozar <tglozar@redhat.com> |
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
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>
show more ...
|
| 92a33d5b | 10-Jul-2026 |
Tomas Glozar <tglozar@redhat.com> |
rtla/cli: Unify and improve range validation logic
Several RTLA options do range validation inside the CLI parser layer (e.g. -p/--period). When RTLA migrated CLI parsing to libsubcmd, this logic wa
rtla/cli: Unify and improve range validation logic
Several RTLA options do range validation inside the CLI parser layer (e.g. -p/--period). When RTLA migrated CLI parsing to libsubcmd, this logic was moved unchanged inside opt_*() callbacks.
Unify range validation so that all options use two newly added functions, check_llong_range() and check_int_range(), to validate the range.
The new range validation returns -1 from opt_*() callbacks rather than hard-exit with fatal(), allowing the help message for the specific option to be automatically displayed by libsubcmd logic.
Many options no longer need a custom callback, as they use the unified range validation of opt_llong_callback() and opt_int_callback(). Validation for several other options is improved:
- timerlat -p/--period: lower bound raised from 1 to 100 us to match the kernel's timerlat_min_period in trace_osnoise.c. - timerlat -A/--aligned: reject negative values. - timerlat --deepest-idle-state: add range [-1, INT_MAX]; previously, values <= -2 were read as "option not set". - timerlat -p/--period, -A/--aligned, -b/--bucket-size: properly reject negative values instead of passing them to the tracer.
Remove unit tests for removed callbacks and test the new range validation functionality of opt_llong_callback() and opt_int_callback().
Update runtime tests for histogram options to account for the new error messages and exit value.
Assisted-by: Claude:claude-opus-4-6 Link: https://lore.kernel.org/r/20260710131554.338335-1-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 03d745b9 | 27-May-2026 |
Tomas Glozar <tglozar@redhat.com> |
rtla/timerlat: Add -A/--aligned CLI option
Add a new option, -A/--aligned, that enables timerlat thread alignment implemented on the kernel-side in commit 4245bf4dc58f ("tracing/osnoise: Add option
rtla/timerlat: Add -A/--aligned CLI option
Add a new option, -A/--aligned, that enables timerlat thread alignment implemented on the kernel-side in commit 4245bf4dc58f ("tracing/osnoise: Add option to align tlat threads"). The option takes an argument, representing alignment between timerlat threads in microseconds.
The feature is modeled after the option of the same name in the cyclictest tool.
Link: https://lore.kernel.org/r/20260527144928.2944472-1-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 596a9bed | 28-May-2026 |
Tomas Glozar <tglozar@redhat.com> |
rtla/tests: Add unit tests for CLI option callbacks
In addition to testing all tool_parse_args() functions, test also all callbacks used for parsing custom option formats.
The callbacks represent a
rtla/tests: Add unit tests for CLI option callbacks
In addition to testing all tool_parse_args() functions, test also all callbacks used for parsing custom option formats.
The callbacks represent a middle layer between the parsing functions and utility functions dedicated to checking specific argument formats, for example, scheduling class and duration. Callback tests are run before parsing functions to make sure any issue in the former is reported before it is encountered through the latter.
Tests verify both successful parsing and proper rejection of invalid inputs (via exit tests). To enable testing static callbacks, a pragma once guard is added to timerlat.h for safe inclusion by cli_p.h.
Add dependency of UNIT_TESTS_IN on LIBSUBCMD_INCLUDES, as the new test file tests/unit/cli_opt_callback.c includes cli_p.h which includes subcmd/parse-options.h.
Link: https://lore.kernel.org/r/20260528103254.2990068-7-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 244d0cbf | 28-May-2026 |
Tomas Glozar <tglozar@redhat.com> |
rtla/tests: Add unit tests for _parse_args() functions
Add a test suite for the _parse_args() function of each tool that checks the params structures (struct common_params, struct osnoise_params, st
rtla/tests: Add unit tests for _parse_args() functions
Add a test suite for the _parse_args() function of each tool that checks the params structures (struct common_params, struct osnoise_params, struct timerlat_params) returned by them for correctness.
One test case is added per option, as well as a few special cases for tricky combinations of options. Test cases are ordered the same as the option arrays and help message to allow easy checking of whether all options are covered.
This should help clarify what the proper command line behavior of RTLA is in case there are holes in the documentation and verify that the intended behavior is implemented correctly.
A few necessary changes to the unit tests were done as part of this commit:
- Unit tests now also link to libsubcmd and its dependencies. - A new global variable in_unit_test is added to RTLA's CLI interface, causing it to skip check for root if running in unit tests. This allows the CLI unit tests to run as non-root, like existing unit tests.
There is quite a lot of duplication, some of it is mitigated with macros, but partially it is intentional so that future changes in behavior are tracked across tools.
Link: https://lore.kernel.org/r/20260528103254.2990068-6-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 5d9af63e | 28-May-2026 |
Tomas Glozar <tglozar@redhat.com> |
rtla: Parse cmdline using libsubcmd
Instead of using getopt_long() directly to parse the command line arguments given to an RTLA tool, use libsubcmd's parse_options().
Utilizing libsubcmd for parsi
rtla: Parse cmdline using libsubcmd
Instead of using getopt_long() directly to parse the command line arguments given to an RTLA tool, use libsubcmd's parse_options().
Utilizing libsubcmd for parsing command line arguments has several benefits:
- A help message is automatically generated by libsubcmd from the specification, removing the need of writing it by hand. - Options are sorted into groups based on which part of tracing (CPU, thread, auto-analysis, tuning, histogram) they relate to. - Common parsing patterns for numerical and boolean values now share code, with the target variable being stored in the option array.
To avoid duplication of the option parsing logic, RTLA-specific macros defining struct option values are created:
- RTLA_OPT_* for options common to all tools - OSNOISE_OPT_* and TIMERLAT_OPT_* for options specific to osnoise/timerlat tools - HIST_OPT_* macros for options specific to histogram-based tools.
Individual *_parse_args() functions then construct an array out of these macros that is then passed to libsubcmd's parse_options().
All code specific to command line options parsing is moved out of the individual tool files into a new file, cli.c, which also contains the contents of the rtla.c file. A private header, cli_p.h, is added alongside the public header cli.h, so that unit tests are able to test statically declared option callbacks.
Minor changes:
- The return value of tool-level help option changes to 129, as this is the value set by libsubcmd; this is reflected in affected test cases. The implementation of help for command-level and tracer-level help is set to 129 as well for consistency, and the change is reflected in exit value documentation. - Related to the above, {rtla,osnoise,timerlat}_usage() are marked __noreturn and exit() is removed from after they are called for cleaner code. - The error messages for invalid argument for options --dma-latency and -E/--entries were corrected, fixing off-by-one in the limits.
Note that unsetting options (using --no-<opt> syntax) is currently not implemented for options that use custom callbacks. For --irq and --thread, it will never be implemented, as they conflict with already existing --no-irq and --no-thread with a different meaning.
Assisted-by: Composer:composer-1.5 Link: https://lore.kernel.org/r/20260528103254.2990068-5-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 48209d76 | 28-May-2026 |
Tomas Glozar <tglozar@redhat.com> |
rtla: Add libsubcmd dependency
In preparation for migrating RTLA to libsubcmd, build libsubcmd from the appropriate directory next to the RTLA build proper, and link the resulting object to RTLA.
l
rtla: Add libsubcmd dependency
In preparation for migrating RTLA to libsubcmd, build libsubcmd from the appropriate directory next to the RTLA build proper, and link the resulting object to RTLA.
libsubcmd uses str_error_r() and strlcpy() at several places. To support these, also link the respective libraries from tools/lib.
For completeness, also add tools/include to include path. This will allow other userspace functions and macros shipped with the kernel to be used in RTLA; perf and bpftool, two other users of libsubcmd, already do that.
To prevent a name conflict, rename RTLA's run_command() function to run_tool_command(), and replace RTLA's own container_of implementation with the one in tools/include/linux/container_of.h.
Assisted-by: Composer:composer-1 Link: https://lore.kernel.org/r/20260528103254.2990068-2-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| dd520daf | 26-May-2026 |
Tomas Glozar <tglozar@redhat.com> |
rtla/actions: Restore continue flag in actions_perform()
Currently, actions_perform() only ever sets the continue flag (when performing the continue action), but never resets it. That leads to RTLA
rtla/actions: Restore continue flag in actions_perform()
Currently, actions_perform() only ever sets the continue flag (when performing the continue action), but never resets it. That leads to RTLA continuing tracing even if the continue action was not performed in the current iteration.
For example, the following command:
$ rtla timerlat hist -T 100 --on-threshold shell,command=' echo Spike! if [ -f /tmp/a ] then exit 1 else touch /tmp/a fi' --on-threshold continue
should print Spike! at most once, because after hitting the threshold for the first time, /tmp/a exists, the shell action will fail, and the continue action is not performed. However, unless /tmp/a exists before the measurement, it will print Spike! until stopped, as the continue flag stays set.
Set the continue flag to false in the beginning of actions_perform() to make RTLA continue only if the action was actually performed.
Fixes: 8d933d5c89e8 ("rtla/timerlat: Add continue action") Link: https://lore.kernel.org/r/20260526102523.2662391-1-tglozar@redhat.com [ correct Fixes tag to include 12 characters of hash ] Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| f03a59f9 | 12-May-2026 |
Crystal Wood <crwood@redhat.com> |
rtla: Stop the record trace on interrupt
Before, when rtla got a signal, it stopped the main trace but not the record trace. With "--on-end trace", this can lead to save_trace_to_file() failing to
rtla: Stop the record trace on interrupt
Before, when rtla got a signal, it stopped the main trace but not the record trace. With "--on-end trace", this can lead to save_trace_to_file() failing to keep up, especially on a debug kernel. Plus, it adds post-stoppage noise to the trace file.
Signed-off-by: Crystal Wood <crwood@redhat.com> Fixes: c73cab9dbed0 ("rtla/timerlat_hist: Stop timerlat tracer on signal") Fixes: a4dfce7559d7 ("rtla/timerlat_top: Stop timerlat tracer on signal") Fixes: 3aadb65db5d6 ("rtla/timerlat: Add action on end feature") Link: https://lore.kernel.org/r/20260512173731.2151841-1-crwood@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| e5d8f227 | 24-Apr-2026 |
Tomas Glozar <tglozar@redhat.com> |
rtla/tests: Add unit tests for actions module
Add unit tests covering all functions in the actions module, including both valid and invalid inputs and all action types, except for actions_perform(),
rtla/tests: Add unit tests for actions module
Add unit tests covering all functions in the actions module, including both valid and invalid inputs and all action types, except for actions_perform(), where only shell and continue actions are tested.
To support testing multiple modules, the unit test build was modified so that it links the entire rtla-in.o file. For this to work, the main() function in rtla.c was declared weak, so that the unit test main is able to override it.
Other included minor changes to unit tests are:
- Make unit test output verbose to show which tests are being run, now that we have more than 3 tests. - Add unit_tests file to .gitignore. - Split unit test sources to one file per test suite, and keep only main() function in unit_tests.c. - Fix Makefile dependencies so that "make unit-tests" will rebuild the binary with the changes in the commit.
Also with the linking the entire rtla-in.o file, it now has rtla's nr_cpus symbol, so the declaration in utils unit tests is made extern.
Assisted-by: Composer:composer-2-fast Link: https://lore.kernel.org/r/20260424140244.958495-1-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 2e8b1a1d | 30-Mar-2026 |
Tomas Glozar <tglozar@redhat.com> |
rtla: Fix build without libbpf header
rtla supports building without libbpf. However, BPF actions patchset [1] adds an include of bpf/libbpf.h into timerlat_bpf.h, which breaks build on systems that
rtla: Fix build without libbpf header
rtla supports building without libbpf. However, BPF actions patchset [1] adds an include of bpf/libbpf.h into timerlat_bpf.h, which breaks build on systems that don't have libbpf headers installed.
This is a leftover from a draft version of the patchset where timerlat_bpf_set_action() (which takes a struct bpf_program * argument) was defined in the header. timerlat_bpf.c already includes bpf/libbpf.h via timerlat.skel.h when libbpf is present.
Remove the redundant include to fix build on systems without libbpf headers.
[1] https://lore.kernel.org/linux-trace-kernel/20251126144205.331954-1-tglozar@redhat.com/T/
Cc: John Kacur <jkacur@redhat.com> Cc: Luis Goncalves <lgoncalv@redhat.com> Cc: Crystal Wood <crwood@redhat.com> Cc: Costa Shulyupin <costa.shul@redhat.com> Link: https://patch.msgid.link/20260330091207.16184-1-tglozar@redhat.com Reported-by: Steven Rostedt (Google) <rostedt@goodmis.org> Closes: https://lore.kernel.org/linux-trace-kernel/20260329122202.65a8b575@robin/ Fixes: 8cd0f08ac72e ("rtla/timerlat: Support tail call from BPF program") Signed-off-by: Tomas Glozar <tglozar@redhat.com> Reviewed-by: Wander Lairson Costa <wander@redhat.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
show more ...
|
| be8058f3 | 10-Mar-2026 |
Tomas Glozar <tglozar@redhat.com> |
rtla: Fix segfault on multiple SIGINTs
Detach stop_trace() from SIGINT/SIGALRM on tool clean-up to prevent it from crashing RTLA by accessing freed memory.
This prevents a crash when multiple SIGIN
rtla: Fix segfault on multiple SIGINTs
Detach stop_trace() from SIGINT/SIGALRM on tool clean-up to prevent it from crashing RTLA by accessing freed memory.
This prevents a crash when multiple SIGINTs are received.
Fixes: d6899e560366 ("rtla/timerlat_hist: Abort event processing on second signal") Fixes: 80967b354a76 ("rtla/timerlat_top: Abort event processing on second signal") Reviewed-by: Wander Lairson Costa <wander@redhat.com> Link: https://lore.kernel.org/r/20260310160725.144443-1-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 99261ccd | 09-Mar-2026 |
Wander Lairson Costa <wander@redhat.com> |
rtla/utils: Fix loop condition in PID validation
The procfs_is_workload_pid() function iterates through a directory entry name to validate if it represents a process ID. The loop condition checks if
rtla/utils: Fix loop condition in PID validation
The procfs_is_workload_pid() function iterates through a directory entry name to validate if it represents a process ID. The loop condition checks if the pointer t_name is non-NULL, but since incrementing a pointer never makes it NULL, this condition is always true within the loop's context. Although the inner isdigit() check catches the NUL terminator and breaks out of the loop, the condition is semantically misleading and not idiomatic for C string processing.
Correct the loop condition from checking the pointer (t_name) to checking the character it points to (*t_name). This ensures the loop terminates when the NUL terminator is reached, aligning with standard C string iteration practices. While the original code functioned correctly due to the existing character validation, this change improves code clarity and maintainability.
Signed-off-by: Wander Lairson Costa <wander@redhat.com> Link: https://lore.kernel.org/r/20260309195040.1019085-19-wander@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 5b6dc659 | 09-Mar-2026 |
Wander Lairson Costa <wander@redhat.com> |
rtla/utils: Fix resource leak in set_comm_sched_attr()
The set_comm_sched_attr() function opens the /proc directory via opendir() but fails to call closedir() on its successful exit path. If the fun
rtla/utils: Fix resource leak in set_comm_sched_attr()
The set_comm_sched_attr() function opens the /proc directory via opendir() but fails to call closedir() on its successful exit path. If the function iterates through all processes without error, it returns 0 directly, leaking the DIR stream pointer.
Fix this by refactoring the function to use a single exit path. A retval variable is introduced to track the success or failure status. All exit points now jump to a unified out label that calls closedir() before the function returns, ensuring the resource is always freed.
Fixes: dada03db9bb19 ("rtla: Remove procps-ng dependency") Signed-off-by: Wander Lairson Costa <wander@redhat.com> Link: https://lore.kernel.org/r/20260309195040.1019085-18-wander@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 47dd74f6 | 09-Mar-2026 |
Wander Lairson Costa <wander@redhat.com> |
rtla/trace: Fix I/O handling in save_trace_to_file()
The read/write loop in save_trace_to_file() does not correctly handle errors from the read() and write() system calls. If either call is interrup
rtla/trace: Fix I/O handling in save_trace_to_file()
The read/write loop in save_trace_to_file() does not correctly handle errors from the read() and write() system calls. If either call is interrupted by a signal, it returns -1 with errno set to EINTR, but the code treats this as a fatal error and aborts the save operation. Additionally, write() may perform a partial write, returning fewer bytes than requested, which the code does not handle.
Fix the I/O loop by introducing proper error handling. The return value of read() is now stored in a ssize_t variable and checked for errors, with EINTR causing a retry. For write(), an inner loop ensures all bytes are written, handling both EINTR and partial writes. Error messages now include strerror() output for better debugging.
This follows the same pattern established in the previous commit that fixed trace_event_save_hist(), ensuring consistent and robust I/O handling throughout the trace saving code.
Signed-off-by: Wander Lairson Costa <wander@redhat.com> Link: https://lore.kernel.org/r/20260309195040.1019085-17-wander@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 4bf4ef52 | 09-Mar-2026 |
Wander Lairson Costa <wander@redhat.com> |
rtla/trace: Fix write loop in trace_event_save_hist()
The write loop in trace_event_save_hist() does not correctly handle errors from the write() system call. If write() returns -1, this value is ad
rtla/trace: Fix write loop in trace_event_save_hist()
The write loop in trace_event_save_hist() does not correctly handle errors from the write() system call. If write() returns -1, this value is added to the loop index, leading to an incorrect memory access on the next iteration and potentially an infinite loop. The loop also fails to handle EINTR.
Fix the write loop by introducing proper error handling. The return value of write() is now stored in a ssize_t variable and checked for errors. The loop retries the call if interrupted by a signal and breaks on any other error after logging it with strerror().
Additionally, change the index variable type from int to size_t to match the type used for buffer sizes and by strlen(), improving type safety.
Fixes: 761916fd02c2 ("rtla/trace: Save event histogram output to a file") Signed-off-by: Wander Lairson Costa <wander@redhat.com> Link: https://lore.kernel.org/r/20260309195040.1019085-16-wander@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 48fbcd4d | 09-Mar-2026 |
Wander Lairson Costa <wander@redhat.com> |
rtla/timerlat: Simplify RTLA_NO_BPF environment variable check
The code that checks the RTLA_NO_BPF environment variable calls getenv() twice and uses strncmp() with a length of 2 to compare against
rtla/timerlat: Simplify RTLA_NO_BPF environment variable check
The code that checks the RTLA_NO_BPF environment variable calls getenv() twice and uses strncmp() with a length of 2 to compare against the single-character string "1". This is inefficient and the comparison length is unnecessarily long.
Store the result of getenv() in a local variable to avoid the redundant call, and replace strncmp() with strncmp_static() for the exact match comparison. This follows the same pattern established in recent commits that improved string comparison consistency throughout the rtla codebase.
Signed-off-by: Wander Lairson Costa <wander@redhat.com> Link: https://lore.kernel.org/r/20260309195040.1019085-15-wander@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| ea5ea835 | 09-Mar-2026 |
Wander Lairson Costa <wander@redhat.com> |
rtla: Use str_has_prefix() for option prefix check
The argument parsing code in timerlat_main() and osnoise_main() uses strncmp() with a length of 1 to check if the first argument starts with a dash
rtla: Use str_has_prefix() for option prefix check
The argument parsing code in timerlat_main() and osnoise_main() uses strncmp() with a length of 1 to check if the first argument starts with a dash, indicating an option flag was passed.
Replace this pattern with str_has_prefix() for consistency with the rest of the codebase. While character comparison would be slightly more efficient, using str_has_prefix() provides better readability and maintains a uniform coding style throughout the rtla tool.
Signed-off-by: Wander Lairson Costa <wander@redhat.com> Link: https://lore.kernel.org/r/20260309195040.1019085-14-wander@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| b3910a73 | 09-Mar-2026 |
Wander Lairson Costa <wander@redhat.com> |
rtla: Enforce exact match for time unit suffixes
The parse_ns_duration() function currently uses prefix matching for detecting time units. This approach is problematic as it silently accepts malform
rtla: Enforce exact match for time unit suffixes
The parse_ns_duration() function currently uses prefix matching for detecting time units. This approach is problematic as it silently accepts malformed strings such as "100nsx" or "100us_invalid" by ignoring the trailing characters, leading to potential configuration errors.
Introduce a match_time_unit() helper that checks the suffix matches exactly and is followed by either end-of-string or a ':' delimiter. The ':' is needed because parse_ns_duration() is also called from get_long_ns_after_colon() when parsing SCHED_DEADLINE priority specifications in the format "d:runtime:period" (e.g., "d:10ms:100ms").
A plain strcmp() would reject valid deadline strings because the suffix "ms" is followed by ":100ms", not end-of-string. Similarly, strncmp_static() would fail because ARRAY_SIZE() includes the NUL terminator, making it equivalent to strcmp() for this comparison.
The match_time_unit() helper solves both problems: it rejects malformed input like "100msx" while correctly handling the colon-delimited deadline format.
Signed-off-by: Wander Lairson Costa <wander@redhat.com> Link: https://lore.kernel.org/r/20260309195040.1019085-13-wander@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|
| 265905df | 09-Mar-2026 |
Wander Lairson Costa <wander@redhat.com> |
rtla: Use str_has_prefix() for prefix checks
The code currently uses strncmp() combined with strlen() to check if a string starts with a specific prefix. This pattern is verbose and prone to errors
rtla: Use str_has_prefix() for prefix checks
The code currently uses strncmp() combined with strlen() to check if a string starts with a specific prefix. This pattern is verbose and prone to errors if the length does not match the prefix string.
Replace this pattern with the str_has_prefix() helper function in both trace.c and utils.c. This improves code readability and safety by handling the prefix length calculation automatically.
In addition, remove the unused retval variable from trace_event_save_hist() in trace.c to clean up the function and silence potential compiler warnings.
Signed-off-by: Wander Lairson Costa <wander@redhat.com> Link: https://lore.kernel.org/r/20260309195040.1019085-12-wander@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
show more ...
|