Repository navigation
a2i() - #1736
Open
alejandro-colomar wants to merge 2 commits into
Open
a2i()#1736alejandro-colomar wants to merge 2 commits into
alejandro-colomar wants to merge 2 commits into
Conversation
This was referenced Oct 30, 2026
alejandro-colomar
force-pushed
the
a2i
branch
2 times, most recently
from
November 3, 2026 12:18
bf30014 to
81898c7
Compare
The str2i() macros were useful back when we didn't have default arguments, to avoid having to specify the limits, which was error-prone. Now that we have default arguments, that danger has vanished, and having the base value explicitly passed seems preferable, as it helps see whether we're using 0 or 10 (both are common bases). Another benefit of this reduction of APIs is that it's easier to grep(1) for all places where we parse integers from strings. Signed-off-by: Alejandro Colomar <alx@kernel.org>
The a2[su]*() macros were special cases for fundamental types, inspired on strtol(3) and strtoll(3), etc. The standard libc is full of examples of multiple APIs that work for different types. However, in this project we've been moving towards APIs that take a type as a parameter, and then work fine with any type that the API supports (these APIs are currently implemented as macros, although future language dialects will likely allow implementing these as functions). The use of a2i() everywhere makes the usage more consistent, since we'll use the same macro both for typedefs and for fundamental types. It will also make it much easier to grep(1) for all places where we parse integers, since one will only have to find all uses of a single API: a2i(). Another benefit is readability. It's much easier to figure out what a2i(int, ...) does than to figure out what a2si(...) does. The only issue would be slightly longer lines. This is more notable with unsigned types. However, even for unsigned types, I realized most lines don't go past the right margin, and those that do don't go much past it, so I find it acceptable, given the other benefits. Signed-off-by: Alejandro Colomar <alx@kernel.org>
alejandro-colomar
force-pushed
the
a2i
branch
from
November 12, 2026 10:34
81898c7 to
66e3372
Compare
alejandro-colomar
marked this pull request as ready for review
November 12, 2026 10:34
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.