There must be one or more iterations, prevent the user from entering a number less than one Signed-off-by: John Kacur <jkacur@xxxxxxxxxx> --- src/ssdd/ssdd.8 | 2 ++ src/ssdd/ssdd.c | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) 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); -- 2.44.0