On Mon, Feb 09, 2026 at 07:47:53PM +0300, Dmitry Antipov wrote:
> In '_parse_integer_limit()', adjust native integer arithmetic
> with near-to-overflow branch where 'check_mul_overflow()' and
> 'check_add_overflow()' are used to check whether an intermediate
> result goes out of range, and denote such a case with ULLONG_MAX,
> thus making the function more similar to standard C library's
> 'strtoull()'. Adjust comment to kernel-doc style as well.
...
> - unsigned long long res;
> + unsigned long long res = 0;
>
> - res = 0;
We can leave this untouched.
...
> - while (max_chars--) {
> + for (rv = 0; max_chars--; rv++, s++) {
I don't see how max_chars is used. With that said, I would rather see the usual
way of expressing the condition in the for-loop:
for (rv = 0; rv < max_chars; rv++, s++) {
...
> + if (likely(res != ULLONG_MAX)) {
Have you seen David's question about these checks?
Maybe I missed your answer...
> + if (unlikely(res & (~0ull << 60))) {
> + /* We're close to possible overflow. */
> + unsigned long long tmp;
> +
> + if (check_mul_overflow(res, base, &tmp) ||
> + check_add_overflow(tmp, val, &res)) {
> + res = ULLONG_MAX;
> + rv |= KSTRTOX_OVERFLOW;
> + }
> + } else {
> + res = res * base + val;
> + }
> }
--
With Best Regards,
Andy Shevchenko