On Sun, Oct 14, 2018 at 03:25:09PM +0200, Christian Brauner wrote:

> +static unsigned long sysctl_strtoul_lenient(const char *cp, char **endp,
> +                                         unsigned int base, bool *overflow)
> +{
> +     unsigned long long result;
> +     unsigned int rv;
> +
> +     cp = _parse_integer_fixup_radix(cp, &base);
> +     rv = _parse_integer(cp, base, &result);
> +     if ((rv & KSTRTOX_OVERFLOW) ||
> +         (result != (unsigned long long)(unsigned long)result))
> +             *overflow = true;
> +     else
> +             *overflow = false;

Yecchh...  First of all, the cast back to unsigned long long is completely
pointless.  What's more,
        if (expr)
                foo = true;
        else
                foo = flase;
is a fairly unidiomatic way to spell foo = expr;

And... is there anything that would really care if this "overflow" thing had
been replaced by simply returning ~0UL on such?  That would appear to be
a lot more natural API...

Reply via email to