]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
tools/rtla: Consolidate -D/--debug option parsing
authorCosta Shulyupin <costa.shul@redhat.com>
Tue, 9 Dec 2025 10:00:43 +0000 (12:00 +0200)
committerTomas Glozar <tglozar@redhat.com>
Wed, 7 Jan 2026 14:57:17 +0000 (15:57 +0100)
Each rtla tool duplicates parsing of -D/--debug.

Migrate the option parsing from individual tools to the
common_parse_options().

Signed-off-by: Costa Shulyupin <costa.shul@redhat.com>
Link: https://lore.kernel.org/r/20251209100047.2692515-4-costa.shul@redhat.com
Signed-off-by: Tomas Glozar <tglozar@redhat.com>
tools/tracing/rtla/src/common.c
tools/tracing/rtla/src/osnoise_hist.c
tools/tracing/rtla/src/osnoise_top.c
tools/tracing/rtla/src/timerlat_hist.c
tools/tracing/rtla/src/timerlat_top.c

index 3400836f66efd10a3a5782cf6ec11900b701b195..f71cf7c7f4e3dc32991b86993935944e48df1c63 100644 (file)
@@ -59,11 +59,12 @@ int common_parse_options(int argc, char **argv, struct common_params *common)
        static struct option long_options[] = {
                {"cpus",                required_argument,      0, 'c'},
                {"cgroup",              optional_argument,      0, 'C'},
+               {"debug",               no_argument,            0, 'D'},
                {0, 0, 0, 0}
        };
 
        opterr = 0;
-       c = getopt_long(argc, argv, "c:C::", long_options, NULL);
+       c = getopt_long(argc, argv, "c:C::D", long_options, NULL);
        opterr = 1;
 
        switch (c) {
@@ -76,6 +77,9 @@ int common_parse_options(int argc, char **argv, struct common_params *common)
                common->cgroup = 1;
                common->cgroup_name = parse_optional_arg(argc, argv);
                break;
+       case 'D':
+               config_debug = 1;
+               break;
        default:
                optind = saved_state;
                return 0;
index bcd4b4c963549560dfc759f87aace6afeef8de25..c9422b596622ffab161c86eff1a01692644e82e8 100644 (file)
@@ -485,7 +485,6 @@ static struct common_params
                        {"auto",                required_argument,      0, 'a'},
                        {"bucket-size",         required_argument,      0, 'b'},
                        {"entries",             required_argument,      0, 'E'},
-                       {"debug",               no_argument,            0, 'D'},
                        {"duration",            required_argument,      0, 'd'},
                        {"house-keeping",       required_argument,              0, 'H'},
                        {"help",                no_argument,            0, 'h'},
@@ -513,7 +512,7 @@ static struct common_params
                if (common_parse_options(argc, argv, &params->common))
                        continue;
 
-               c = getopt_long(argc, argv, "a:b:d:e:E:DhH:p:P:r:s:S:t::T:01234:5:6:7:",
+               c = getopt_long(argc, argv, "a:b:d:e:E:hH:p:P:r:s:S:t::T:01234:5:6:7:",
                                 long_options, NULL);
 
                /* detect the end of the options. */
@@ -539,9 +538,6 @@ static struct common_params
                            params->common.hist.bucket_size >= 1000000)
                                fatal("Bucket size needs to be > 0 and <= 1000000");
                        break;
-               case 'D':
-                       config_debug = 1;
-                       break;
                case 'd':
                        params->common.duration = parse_seconds_duration(optarg);
                        if (!params->common.duration)
index 2799dd75a4e2ac3b80a2745b0b06872e6865978e..8d49042d10f0d01fcdc6f11f2fcfde528ddc6545 100644 (file)
@@ -339,7 +339,6 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
        while (1) {
                static struct option long_options[] = {
                        {"auto",                required_argument,      0, 'a'},
-                       {"debug",               no_argument,            0, 'D'},
                        {"duration",            required_argument,      0, 'd'},
                        {"event",               required_argument,      0, 'e'},
                        {"house-keeping",       required_argument,      0, 'H'},
@@ -364,7 +363,7 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
                if (common_parse_options(argc, argv, &params->common))
                        continue;
 
-               c = getopt_long(argc, argv, "a:d:De:hH:p:P:qr:s:S:t::T:0:1:2:3:",
+               c = getopt_long(argc, argv, "a:d:e:hH:p:P:qr:s:S:t::T:0:1:2:3:",
                                 long_options, NULL);
 
                /* Detect the end of the options. */
@@ -383,9 +382,6 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
                        if (!trace_output)
                                trace_output = "osnoise_trace.txt";
 
-                       break;
-               case 'D':
-                       config_debug = 1;
                        break;
                case 'd':
                        params->common.duration = parse_seconds_duration(optarg);
index 64c1dbb1fccc608e5724aa41fce4dac5b048bedd..c08f628047c1d26581a34fc8bb9c3d470b853d20 100644 (file)
@@ -792,7 +792,6 @@ static struct common_params
                static struct option long_options[] = {
                        {"auto",                required_argument,      0, 'a'},
                        {"bucket-size",         required_argument,      0, 'b'},
-                       {"debug",               no_argument,            0, 'D'},
                        {"entries",             required_argument,      0, 'E'},
                        {"duration",            required_argument,      0, 'd'},
                        {"house-keeping",       required_argument,      0, 'H'},
@@ -831,7 +830,7 @@ static struct common_params
                if (common_parse_options(argc, argv, &params->common))
                        continue;
 
-               c = getopt_long(argc, argv, "a:b:d:e:E:DhH:i:knp:P:s:t::T:uU0123456:7:8:9\1\2:\3:",
+               c = getopt_long(argc, argv, "a:b:d:e:E:hH:i:knp:P:s:t::T:uU0123456:7:8:9\1\2:\3:",
                                 long_options, NULL);
 
                /* detect the end of the options. */
@@ -860,9 +859,6 @@ static struct common_params
                            params->common.hist.bucket_size >= 1000000)
                                fatal("Bucket size needs to be > 0 and <= 1000000");
                        break;
-               case 'D':
-                       config_debug = 1;
-                       break;
                case 'd':
                        params->common.duration = parse_seconds_duration(optarg);
                        if (!params->common.duration)
index bdc8bf265836b047a68b07babd172f48b3c8b932..7c0a3f5822736e96b09e03d06f9703f313e1ac9f 100644 (file)
@@ -561,7 +561,6 @@ static struct common_params
        while (1) {
                static struct option long_options[] = {
                        {"auto",                required_argument,      0, 'a'},
-                       {"debug",               no_argument,            0, 'D'},
                        {"duration",            required_argument,      0, 'd'},
                        {"event",               required_argument,      0, 'e'},
                        {"help",                no_argument,            0, 'h'},
@@ -595,7 +594,7 @@ static struct common_params
                if (common_parse_options(argc, argv, &params->common))
                        continue;
 
-               c = getopt_long(argc, argv, "a:d:De:hH:i:knp:P:qs:t::T:uU0:1:2:345:6:7:",
+               c = getopt_long(argc, argv, "a:d:e:hH:i:knp:P:qs:t::T:uU0:1:2:345:6:7:",
                                 long_options, NULL);
 
                /* detect the end of the options. */
@@ -632,9 +631,6 @@ static struct common_params
                        /* set aa_only to avoid parsing the trace */
                        params->common.aa_only = 1;
                        break;
-               case 'D':
-                       config_debug = 1;
-                       break;
                case 'd':
                        params->common.duration = parse_seconds_duration(optarg);
                        if (!params->common.duration)