On Thu, Jan 08, 2026 at 07:52:15PM +0300, Dmitry Antipov wrote:
> Introduce 'memvalue()' which uses 'memparse()' to parse a string
> with optional memory suffix into a non-negative number. If parsing
> has succeeded, returns 0 and stores the result at the location
> specified by the second argument. Otherwise returns -EINVAL and
> leaves the location untouched.
...
> +int __must_check memvalue(const char *ptr, unsigned long long *valptr)
> +{
> + unsigned long long ret;
> + char *end;
> +
> + if (*ptr == '-')
> + return -EINVAL;
Hmm... Why not -ERANGE (IIRC this what kstrto*() returns when it doesn't match
the given range).
> + ret = memparse(ptr, &end);
> + if (*end)
> + return -EINVAL;
> + *valptr = ret;
> + return 0;
> +}
--
With Best Regards,
Andy Shevchenko