Skip to content

Commit e9071f4

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: Po-Ying Chiu <[email protected]> Change-Id: I6741888f888523d00f83cd554fc1442e99120a64
1 parent aec0044 commit e9071f4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: qtest.c

+2-2
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 (at least 1)");
828828
return false;
829829
}
830830
} else {

0 commit comments

Comments
 (0)