Skip to content

Reflection: use std::strtol instead of std::atoi #3129

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

Merged
merged 1 commit into from
Jun 23, 2016

Conversation

compnerd
Copy link
Member

What's in this pull request?

Resolved bug number: (SR-)


Before merging this pull request to apple/swift repository:

  • Test pull request on Swift continuous integration.

Triggering Swift CI

The swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:

Smoke Testing

Platform Comment
All supported platforms @swift-ci Please smoke test
All supported platforms @swift-ci Please smoke test and merge
OS X platform @swift-ci Please smoke test OS X platform
Linux platform @swift-ci Please smoke test Linux platform

Validation Testing

Platform Comment
All supported platforms @swift-ci Please test
All supported platforms @swift-ci Please test and merge
OS X platform @swift-ci Please test OS X platform
OS X platform @swift-ci Please benchmark
Linux platform @swift-ci Please test Linux platform

Lint Testing

Language Comment
Python @swift-ci Please Python lint

Note: Only members of the Apple organization can trigger swift-ci.

Address post-commit review comments from Harlan. Use std::strtol as it can
deal with hex and octal inputs.

@gribozavr
Copy link
Contributor

We don't care about hex and octal digits here, the code above makes sure the digits are only 0...9. This code is parsing mangled names.

@compnerd
Copy link
Member Author

Thats what I thought to (which is why I opted to use atoi). @harlanhaskins asked for this change though.

@harlanhaskins
Copy link
Contributor

I suggested it before seeing the validation beforehand. I suppose atoi is alright, but the lack of failure reporting in atoi raises a red flag

@compnerd
Copy link
Member Author

@harlanhaskins okay, so whats the plan on this? Are we happy with the code as is and this can be abandoned or do we want to pursue some changes here?

@harlanhaskins
Copy link
Contributor

I'm hesitantly okay with this now. Sorry for stirring the pot.

@gribozavr
Copy link
Contributor

I see the benefit in using strtol as long as we actually check the error code.

Address post-commit review comments from Harlan.  Use `std::strtol` as it can
deal with hex and octal inputs.
@compnerd
Copy link
Member Author

@gribozavr updated with the error handling, but Im really not sure how much it buys us. I did also remove an allocation, which can be nice, but, really, Im not convinced that it really is an improvement. Note that it previously didnt have any error handling either.

@gribozavr
Copy link
Contributor

@swift-ci Please test and merge

@swift-ci swift-ci merged commit 6fd8e98 into swiftlang:master Jun 23, 2016
@compnerd compnerd deleted the integer-parsing branch July 3, 2016 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants