Skip to content

Commit 49c1579

Browse files
makelinuxlenticularis39
authored andcommitted
tools/rtla: Replace osnoise_hist_usage("...") with fatal("...")
A long time ago, when the usage help was short, it was a favor to the user to show it on error. Now that the usage help has become very long, it is too noisy to dump the complete help text for each typo after the error message itself. Replace osnoise_hist_usage("...") with fatal("...") on errors. Remove the already unused 'usage' argument from osnoise_hist_usage(). Signed-off-by: Costa Shulyupin <costa.shul@redhat.com> Reviewed-by: Tomas Glozar <tglozar@redhat.com> Link: https://lore.kernel.org/r/20251011082738.173670-6-costa.shul@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
1 parent 92b5b55 commit 49c1579

1 file changed

Lines changed: 13 additions & 19 deletions

File tree

tools/tracing/rtla/src/osnoise_hist.c

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ osnoise_print_stats(struct osnoise_tool *tool)
407407
/*
408408
* osnoise_hist_usage - prints osnoise hist usage message
409409
*/
410-
static void osnoise_hist_usage(char *usage)
410+
static void osnoise_hist_usage(void)
411411
{
412412
int i;
413413

@@ -453,18 +453,12 @@ static void osnoise_hist_usage(char *usage)
453453
NULL,
454454
};
455455

456-
if (usage)
457-
fprintf(stderr, "%s\n", usage);
458-
459456
fprintf(stderr, "rtla osnoise hist: a per-cpu histogram of the OS noise (version %s)\n",
460457
VERSION);
461458

462459
for (i = 0; msg[i]; i++)
463460
fprintf(stderr, "%s\n", msg[i]);
464461

465-
if (usage)
466-
exit(EXIT_FAILURE);
467-
468462
exit(EXIT_SUCCESS);
469463
}
470464

@@ -547,12 +541,12 @@ static struct common_params
547541
params->common.hist.bucket_size = get_llong_from_str(optarg);
548542
if (params->common.hist.bucket_size == 0 ||
549543
params->common.hist.bucket_size >= 1000000)
550-
osnoise_hist_usage("Bucket size needs to be > 0 and <= 1000000\n");
544+
fatal("Bucket size needs to be > 0 and <= 1000000");
551545
break;
552546
case 'c':
553547
retval = parse_cpu_set(optarg, &params->common.monitored_cpus);
554548
if (retval)
555-
osnoise_hist_usage("\nInvalid -c cpu list\n");
549+
fatal("Invalid -c cpu list");
556550
params->common.cpus = optarg;
557551
break;
558552
case 'C':
@@ -571,7 +565,7 @@ static struct common_params
571565
case 'd':
572566
params->common.duration = parse_seconds_duration(optarg);
573567
if (!params->common.duration)
574-
osnoise_hist_usage("Invalid -D duration\n");
568+
fatal("Invalid -D duration");
575569
break;
576570
case 'e':
577571
tevent = trace_event_alloc(optarg);
@@ -587,11 +581,11 @@ static struct common_params
587581
params->common.hist.entries = get_llong_from_str(optarg);
588582
if (params->common.hist.entries < 10 ||
589583
params->common.hist.entries > 9999999)
590-
osnoise_hist_usage("Entries must be > 10 and < 9999999\n");
584+
fatal("Entries must be > 10 and < 9999999");
591585
break;
592586
case 'h':
593587
case '?':
594-
osnoise_hist_usage(NULL);
588+
osnoise_hist_usage();
595589
break;
596590
case 'H':
597591
params->common.hk_cpus = 1;
@@ -602,18 +596,18 @@ static struct common_params
602596
case 'p':
603597
params->period = get_llong_from_str(optarg);
604598
if (params->period > 10000000)
605-
osnoise_hist_usage("Period longer than 10 s\n");
599+
fatal("Period longer than 10 s");
606600
break;
607601
case 'P':
608602
retval = parse_prio(optarg, &params->common.sched_param);
609603
if (retval == -1)
610-
osnoise_hist_usage("Invalid -P priority");
604+
fatal("Invalid -P priority");
611605
params->common.set_sched = 1;
612606
break;
613607
case 'r':
614608
params->runtime = get_llong_from_str(optarg);
615609
if (params->runtime < 100)
616-
osnoise_hist_usage("Runtime shorter than 100 us\n");
610+
fatal("Runtime shorter than 100 us");
617611
break;
618612
case 's':
619613
params->common.stop_us = get_llong_from_str(optarg);
@@ -653,7 +647,7 @@ static struct common_params
653647
if (retval)
654648
fatal("Error adding trigger %s", optarg);
655649
} else {
656-
osnoise_hist_usage("--trigger requires a previous -e\n");
650+
fatal("--trigger requires a previous -e");
657651
}
658652
break;
659653
case '5': /* filter */
@@ -662,7 +656,7 @@ static struct common_params
662656
if (retval)
663657
fatal("Error adding filter %s", optarg);
664658
} else {
665-
osnoise_hist_usage("--filter requires a previous -e\n");
659+
fatal("--filter requires a previous -e");
666660
}
667661
break;
668662
case '6':
@@ -684,7 +678,7 @@ static struct common_params
684678
fatal("Invalid action %s", optarg);
685679
break;
686680
default:
687-
osnoise_hist_usage("Invalid option");
681+
fatal("Invalid option");
688682
}
689683
}
690684

@@ -695,7 +689,7 @@ static struct common_params
695689
fatal("rtla needs root permission");
696690

697691
if (params->common.hist.no_index && !params->common.hist.with_zeros)
698-
osnoise_hist_usage("no-index set and with-zeros not set - it does not make sense");
692+
fatal("no-index set and with-zeros not set - it does not make sense");
699693

700694
return &params->common;
701695
}

0 commit comments

Comments
 (0)