Re: [PATCH] kstrto*: converting strings to integers done(hopefully) right

From: Alexey Dobriyan
Date: Wed Mar 02 2011 - 03:05:51 EST


On Tue, Mar 01, 2011 at 03:24:55PM -0800, Andrew Morton wrote:
> On Sat, 26 Feb 2011 14:47:08 +0200
> Alexey Dobriyan <adobriyan@xxxxxxxxx> wrote:

> > Use kstrto*() in code today!
>
> If you can stomach perl, please prepare a checkpatch patch which alerts
> people to the new regime.

Ehh, checkpatch was updated.
scripts/checkpatch.pl | 4

> > Let's merge this into mainline, so I can send individual patches
> > to subsystem maintainers. Whole tree is already converted locally.
>
> Talk to us about the tighter checking. There's a risk here that
> current userspace which "works" will cease to work if we add additional
> input checking. Even if that userspace was broken and
> just-happened-to-work, adding additional checks might cause disruption?

What strict_ family of functions errorneously does is to not check for
integer overflow in the result, so it'll happily eat a very long string
full of _valid_ digits: "0xffffffffffffffffffffffffffffffffffffffffffff"
will be converted to unsigned long even if it doesn't fit.
But people don't use such long strings, so the risk is low.

Also, kstrto*() allow to use leading '+' for positive values,
which is not restriction.

The rest should be the same.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/