Re:“People who implement new and improved interfaces always ...
by mikeash on Friday September 11, 2015 @12:41PM
(#10204681)
Returning 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.
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/