-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Ensure K value in reverseK is at least 1 #266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
qtest.c
Outdated
if (!get_int(argv[1], &k)) { | ||
report(1, "Invalid number of K"); | ||
if (!get_int(argv[1], &k) || k < 1) { | ||
report(1, "Invalid number of K = '%s'", argv[1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refine the error message, addressing the valid range (at least 1).
461f8d0
to
d403b28
Compare
qtest.c
Outdated
if (!get_int(argv[1], &k)) { | ||
report(1, "Invalid number of K"); | ||
if (!get_int(argv[1], &k) || k < 1) { | ||
report(1, "Invalid number of K = '%s' (at least 1)", argv[1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not necessary to print the value when K < 1. Improve the wording.
d403b28
to
273722d
Compare
qtest.c
Outdated
if (!get_int(argv[1], &k)) { | ||
report(1, "Invalid number of K"); | ||
if (!get_int(argv[1], &k) || k < 1) { | ||
report(1, "Invalid number of K (at least 1)", argv[1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check format string.
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 <charlie910417@gmail.com> Change-Id: I6741888f888523d00f83cd554fc1442e99120a64
273722d
to
e9071f4
Compare
Thank @EricccTaiwan for contributing! |
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.
Change-Id: Ic68c1acbbd45153da8c3d7682d9251eec9ce597f
Before
After