]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
rtla: Use str_has_prefix() for option prefix check
authorWander Lairson Costa <wander@redhat.com>
Mon, 9 Mar 2026 19:46:26 +0000 (16:46 -0300)
committerTomas Glozar <tglozar@redhat.com>
Wed, 11 Mar 2026 14:29:50 +0000 (15:29 +0100)
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>
tools/tracing/rtla/src/osnoise.c
tools/tracing/rtla/src/timerlat.c

index 9d1fd9981fe91345ca03c5644b77585b6bd13ca0..2db3db155c44a39e5f9a3facbed63c03d1c977fc 100644 (file)
@@ -1210,7 +1210,7 @@ int osnoise_main(int argc, char *argv[])
 
        if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0)) {
                osnoise_usage(0);
-       } else if (strncmp(argv[1], "-", 1) == 0) {
+       } else if (str_has_prefix(argv[1], "-")) {
                /* the user skipped the tool, call the default one */
                run_tool(&osnoise_top_ops, argc, argv);
                exit(0);
index 8a44537e25cb5642dd096bd04bd24d958a797b1f..de3caea433adaf1e939963f0a9037365d6fa6539 100644 (file)
@@ -269,7 +269,7 @@ int timerlat_main(int argc, char *argv[])
 
        if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0)) {
                timerlat_usage(0);
-       } else if (strncmp(argv[1], "-", 1) == 0) {
+       } else if (str_has_prefix(argv[1], "-")) {
                /* the user skipped the tool, call the default one */
                run_tool(&timerlat_top_ops, argc, argv);
                exit(0);