Re: [PATCH v2 1/2] kernel.h: Update comment about simple_strto<foo>() functions

From: Geert Uytterhoeven
Date: Thu Jul 04 2019 - 03:15:03 EST


Hi Andy,

On Wed, Jul 3, 2019 at 4:37 PM Andy Shevchenko
<andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
> On Wed, Jun 26, 2019 at 01:00:45PM +0200, Geert Uytterhoeven wrote:
> > On Wed, Jun 26, 2019 at 11:39 AM Andy Shevchenko
> > <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
> > > --- a/include/linux/kernel.h
> > > +++ b/include/linux/kernel.h
> >
> > > @@ -437,7 +435,15 @@ static inline int __must_check kstrtos32_from_user(const char __user *s, size_t
> > > return kstrtoint_from_user(s, count, base, res);
> > > }
> > >
> > > -/* Obsolete, do not use. Use kstrto<foo> instead */
> > > +/*
> > > + * Use kstrto<foo> instead.
> > > + *
> > > + * NOTE: The simple_strto<foo> does not check for overflow and,
> > > + * depending on the input, may give interesting results.
> > > + *
> > > + * Use these functions if and only if the code will need in place
> > > + * conversion and otherwise looks very ugly. Keep in mind above caveat.
> >
> > What do you mean by "in place conversion"?
> > The input buffer is const, and not modified by the callee.
> > Do you mean that these functions do not require NUL termination (just
> > after the number), and the characters making up the number don't have to
> > be copied to a separate buffer to make them NUL-terminated?
>
> The second one, could you propose better wording for that?

What about:

"Use these functions if and only if you cannot use kstrto<foo>, because
the number is not immediately followed by a NUL-character in the buffer.
Keep in mind above caveat."

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