-
Notifications
You must be signed in to change notification settings - Fork 6k
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
common/strtol.cc: Get error testing also to work on FreeBSD #12034
Conversation
@@ -28,6 +28,17 @@ long long strict_strtoll(const char *str, int base, std::string *err) | |||
errno = 0; /* To distinguish success/failure after call (see man page) */ | |||
long long ret = strtoll(str, &endptr, base); | |||
|
|||
if (endptr == str |
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.
can we just put
if (endptr == str && ret == 0) {
...
see http://pubs.opengroup.org/onlinepubs/9699919799/functions/strtol.html,
If the subject sequence is empty or does not have the expected form, no conversion is performed; the value of nptr shall be stored in the object pointed to by endptr, provided that endptr is not a null pointer.
and
Upon successful completion, these functions shall return the converted value, if any. If no conversion could be performed, 0 shall be returned [CX] [Option Start] and errno may be set to [EINVAL]. [Option End]
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.
@tchaikov
Could be that the FreeSD version is not 100% compliant...
Reason for this change is that in a test the "wrong" error messages was returned.
An that was because ret == 0
and errno == EINVAL
Which triggered the first case.
Linux however chooses to not set errno != 0
but has str == endptr
and selects the second case.
FreeBSD does indeed also set:
If there were no digits at all, however, strtoll()
stores the original value of nptr in *endptr.
So perhaps just reversing the tests would already work.
I'll test that and adjust the PR if that works.
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.
- change order of testing - But report the same error types. - Changed to report for the last error since the value is there but not allowed characters follow. Error found by: run-cli-tests, because the wrong string was returned. Signed-off-by: Willem Jan Withagen <wjw@digiware.nl>
1b1485f
to
ce47832
Compare
|
retest this please, jenkins! |
jenkins test this please (eio now ignored in master) |
|
retest this please |
@tchaikov I saw that error a few times. Do you know if there is an issue about it ? |
@dachary no, seems tracker does not have a ticket tracking it yet. |
@tchaikov ack. I'll create one the next time it shows. |
not allowed characters follow.
Error found by: run-cli-tests, because the wrong string was returned.
Signed-off-by: Willem Jan Withagen wjw@digiware.nl