Re: [PATCH v15 03/12] lib: kstrtox: add kstrtoudec64() and kstrtodec64()
From: Andy Shevchenko
Date: Wed Jun 03 2026 - 04:38:58 EST
On Wed, Jun 03, 2026 at 09:13:40AM +0100, Rodrigo Alencar wrote:
> On 26/06/03 12:00AM, Andy Shevchenko wrote:
> > On Sun, May 31, 2026 at 09:30:46AM +0100, Rodrigo Alencar via B4 Relay wrote:
...
> > > +static int _kstrtoudec64(const char *s, unsigned int scale, u64 *res)
> > > +{
> > > + u64 _res = 0;
> > > + unsigned int rv_int, rv_frac;
> > > +
> > > + rv_int = _parse_integer(s, 10, &_res);
> > > + if (rv_int & KSTRTOX_OVERFLOW)
> > > + return -ERANGE;
> > > + s += rv_int;
> > > +
> > > + if (*s == '.')
> > > + s++; /* skip decimal point */
> > > +
> > > + rv_frac = _parse_integer_limit_init(s, 10, _res, &_res, scale);
> > > + if (rv_frac & KSTRTOX_OVERFLOW)
> > > + return -ERANGE;
> > > + s += rv_frac;
> >
> > > + if (!rv_int && !rv_frac && !isdigit(*s))
> >
> > Do we care about isdigit() here? Why?
>
> The check here validates the presence of digits, and
> this is to cover a corner case with scale = 0 and s = ".5",
> which is considered a valid input and leads to rv_int = 0 and
> rv_frac = 0, outputing res = 0
Please, add a comment on top of this check.
--
With Best Regards,
Andy Shevchenko