On Fri, Jan 09, 2026 at 02:05:41PM +0300, Dmitry Antipov wrote:
> On Thu, 2026-01-08 at 22:10 +0200, Andy Shevchenko wrote:
>
> > Hmm... Why not -ERANGE (IIRC this what kstrto*() returns when it doesn't
> > match
> > the given range).
>
> Well, I've always treated -ERANGE closer to formal math, i.e. "return -ERANGE
> if X is not in [A:B)", rather than using it to denote something which makes
> no practical sense in some particular context, like negative amount of memory
> or negative string length.
Well, I'm not talking about your preferences, I'm talking about the change you
made. First of all,
if (rv & KSTRTOX_OVERFLOW)
return -ERANGE;
is in the original kstrtox implementation that suggests that the code is
already established for the purpose. Second, the bigger issue, the two
semantically different error paths return the same error code when it can
be easily avoided.
--
With Best Regards,
Andy Shevchenko