diff mbox series

rt-tests:ssdd: Ensure there are one or more iterations

Message ID 20240405224647.102211-1-jkacur@redhat.com
State New
Headers show
Series rt-tests:ssdd: Ensure there are one or more iterations | expand

Commit Message

John Kacur April 5, 2024, 10:46 p.m. UTC
There must be one or more iterations, prevent the user from
entering a number less than one

Signed-off-by: John Kacur <jkacur@redhat.com>
---
 src/ssdd/ssdd.8 | 2 ++
 src/ssdd/ssdd.c | 5 ++++-
 2 files changed, 6 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/src/ssdd/ssdd.8 b/src/ssdd/ssdd.8
index e6be5ef6a27d..71cb71ad0817 100644
--- a/src/ssdd/ssdd.8
+++ b/src/ssdd/ssdd.8
@@ -26,6 +26,8 @@  number of PTRACE_SINGLESTEP iterations to do before declaring
 success, for each tracer tracee pair set up.
 .br
 Default is 10,000.
+.br
+NUM must be at least 1
 .TP
 .B \-\-json=FILENAME
 Write final results into FILENAME, JSON formatted.
diff --git a/src/ssdd/ssdd.c b/src/ssdd/ssdd.c
index cad901b563d8..45f6a23910ca 100644
--- a/src/ssdd/ssdd.c
+++ b/src/ssdd/ssdd.c
@@ -80,7 +80,7 @@  static void usage(int error)
 	       "-h       --help            print this message\n"
 	       "         --json=FILENAME   write final results into FILENAME, JSON formatted\n"
 	       "-q       --quiet           suppress running output\n"
-	       "-i       --iters=NUM       number of iterations\n"
+	       "-i       --iters=NUM       number of iterations, NUM must be at least 1\n"
 	       );
 	exit(error);
 }
@@ -331,6 +331,9 @@  int main(int argc, char **argv)
 		case 'i':
 		case OPT_NITERS:
 			nsteps = atoi(optarg);
+			if (nsteps < 1) {
+				usage(0);
+			}
 			break;
 		default:
 			usage(1);