diff mbox series

[05/17] rt-tests: cyclictest: Check user supplies an value to histogram

Message ID 20211111204207.10167-5-jkacur@redhat.com
State New
Headers show
Series [01/17] rt-tests:hwlatdetect: Remove useless object in class declaration | expand

Commit Message

John Kacur Nov. 11, 2021, 8:41 p.m. UTC
histogram and histofall take a required argument.

If the user fails to supply one, display the help and exit with an error

Signed-off-by: John Kacur <jkacur@redhat.com>
---
 src/cyclictest/cyclictest.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index 2187d98de725..e4d43481de97 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -1089,7 +1089,10 @@  static void process_options(int argc, char *argv[], int max_cpus)
 			histofall = 1; /* fall through */
 		case 'h':
 		case OPT_HISTOGRAM:
-			histogram = atoi(optarg); break;
+			histogram = atoi(optarg);
+			if (!histogram)
+				display_help(1);
+			break;
 		case OPT_HISTFILE:
 			use_histfile = 1;
 			strncpy(histfile, optarg, strnlen(optarg, MAX_PATH-1));