Skip to content

Commit 461f8d0

Browse files
Ensure K value in reverseK is at least 1
Passing 0 or a negative value for K does not cause errors, as the input is an integer. However, this behavior may be confusing for users. To improve clarity, enforce K to be an integer greater than or equal to 1 and return an error if the input is invalid. Co-authored-by: charliechiou <[email protected]>
1 parent e83f2fb commit 461f8d0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

qtest.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -823,8 +823,8 @@ static bool do_reverseK(int argc, char *argv[])
823823
error_check();
824824

825825
if (argc == 2) {
826-
if (!get_int(argv[1], &k)) {
827-
report(1, "Invalid number of K");
826+
if (!get_int(argv[1], &k) || k < 1) {
827+
report(1, "Invalid number of K = '%s'", argv[1]);
828828
return false;
829829
}
830830
} else {

0 commit comments

Comments
 (0)