3 ms·
> And yes, parse_integer() really can return an error, even despite that "isdigit(*str)" check. Think about it. Or just read the source code. Actually taking t
by saurik 11y ago
> And yes, parse_integer() really can return an error, even despite that "isdigit(*str)" check. Think about it. Or just read the source code.
Actually taking the advice of the article and looking at the source code makes it clear that parse_integer is doing what we would hope such an API would: it guarantees that the resulting number fits into the provided integer.
https://lwn.net/Articles/643159/ https://lwn.net/Articles/643159/
- mikeash 11y agoReturning an error is fine, but the code that calls the function doesn't check for errors, and just blindly applies the return value as an offset to a pointer. When the function returns -ERANGE to indicate that the value was too large for the requested data type, entertaining things will occur.