[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120712221622.GD24162@fieldses.org>
Date: Thu, 12 Jul 2012 18:16:22 -0400
From: "J. Bruce Fields" <bfields@...ldses.org>
To: Eldad Zack <eldad@...refinery.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Joe Perches <joe@...ches.com>,
open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/2] kstrto*: add documentation
On Fri, Jul 13, 2012 at 12:09:37AM +0200, Eldad Zack wrote:
>
> On Thu, 12 Jul 2012, J. Bruce Fields wrote:
> > On Thu, Jul 12, 2012 at 10:53:13PM +0200, Eldad Zack wrote:
> > > +/**
> > > + * kstrtoul - convert a string to an unsigned long
> >
> > Also, is it worth mentioning that the number is required to be followed
> > by a string or newline?
>
> I am not sure if I understand _parse_integer correctly (which is called
> to do the actual parsing and has a very nice comment to it) - but it
> expects a null-terminated string, but will also stop as soon as it
> bumps into any other non-number character without error (please correct
> me I'm wrong).
I believe it, but, in _kstrtoull:
rv = _parse_integer(s, base, &_res);
if (rv & KSTRTOX_OVERFLOW)
return -ERANGE;
rv &= ~KSTRTOX_OVERFLOW;
if (rv == 0)
return -EINVAL;
s += rv;
if (*s == '\n')
s++;
if (*s)
return -EINVAL;
So actually it appears the string must be all numeric except possibly a final
newline.
--b.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists