Re: [PATCH 01/52] kstrtox: converting strings to integers done(hopefully) right

From: Geert Uytterhoeven
Date: Sat Feb 05 2011 - 09:33:47 EST


On Sat, Feb 5, 2011 at 15:20, Alexey Dobriyan <adobriyan@xxxxxxxxx> wrote:
> --- /dev/null
> +++ b/lib/kstrtox.c
> @@ -0,0 +1,227 @@
> +/*
> + * Convert integer string representation to an integer.
> + * If an integer doesn't fit into specified type, -E is returned.

Which -E? Currently it returns -EINVAL everywhere.

> +int _kstrtoul(const char *s, unsigned int base, unsigned long *res)
> +{
> + Â Â Â unsigned long long tmp;
> + Â Â Â int rv;
> +
> + Â Â Â rv = kstrtoull(s, base, &tmp);
> + Â Â Â if (rv < 0)
> + Â Â Â Â Â Â Â return rv;
> + Â Â Â if (tmp != (unsigned long long)(unsigned long)tmp)
> + Â Â Â Â Â Â Â return -EINVAL;

-ERANGE for out-of-range?

Gr{oetje,eeting}s,

            Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
             Â Â -- Linus Torvalds
--
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/