Re: [PATCH v8 02/10] lib: kstrtox: add kstrntoull() helper

From: Andy Shevchenko

Date: Tue Mar 03 2026 - 08:57:09 EST


On Tue, Mar 03, 2026 at 01:27:07PM +0000, Rodrigo Alencar via B4 Relay wrote:

> Add kstrntoull() function, which converts a string to an ULL with a max
> character limit. The function is an alternative integer parsing function
> that does not require a null-terminated string. It becomes a better option

null --> NUL

> over simple_strtoull() or kstrtoull() when parsing integers from a buffer
> with custom delimiters without having to create temporary copies.
> The function is consumed inside the implementation _kstrtoull(),
> promoting reuse.

But this will not properly convert 0000000000000000000000000000000000000000100,
for example, if the max_chars say set to 20.

Also kstrto*() have a common idea behind to consume the only \n and allowed
digits. This (naming) doesn't fit into the kstrto*() category.

--
With Best Regards,
Andy Shevchenko