2014-12-17 11:56:28

by samuel kihahu

[permalink] [raw]
Subject: [PATCH] staging: speakup: replace simple_strtoul with kstrtoul

Replacing obsolete simple_strtoul with kstrtoul.

Signed-off-by: samuel kihahu <[email protected]>
---
drivers/staging/speakup/varhandlers.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/speakup/varhandlers.c b/drivers/staging/speakup/varhandlers.c
index d758284..b526c8e 100644
--- a/drivers/staging/speakup/varhandlers.c
+++ b/drivers/staging/speakup/varhandlers.c
@@ -323,7 +323,7 @@ char *spk_s2uchar(char *start, char *dest)
{
int val = 0;

- val = simple_strtoul(skip_spaces(start), &start, 10);
+ val = kstrtoul(skip_spaces(start), &start, 10);
if (*start == ',')
start++;
*dest = (u_char)val;
--
1.8.3.1


2014-12-17 12:11:44

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH] staging: speakup: replace simple_strtoul with kstrtoul

On Wed, Dec 17, 2014 at 02:56:02PM +0300, samuel kihahu wrote:
> Replacing obsolete simple_strtoul with kstrtoul.
>

Nope. That's wrong. Learn how the functions are different beyond just
the name.

regards,
dan carpenter

2014-12-17 13:44:09

by samuel kihahu

[permalink] [raw]
Subject: Re: [PATCH] staging: speakup: replace simple_strtoul with kstrtoul

On Wed, Dec 17, 2014 at 03:11:19PM +0300, Dan Carpenter wrote:
> On Wed, Dec 17, 2014 at 02:56:02PM +0300, samuel kihahu wrote:
> > Replacing obsolete simple_strtoul with kstrtoul.
> >
>
> Nope. That's wrong. Learn how the functions are different beyond just
> the name.
Noted, have made corrections to fit the kstrtoul and handle the return
value.


Attachments:
(No filename) (353.00 B)
0001-staging-speakup-replace-simple_strtoul-with-kstrtoul.patch (992.00 B)
Download all attachments

2014-12-17 14:03:45

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH] staging: speakup: replace simple_strtoul with kstrtoul

On Wed, Dec 17, 2014 at 04:43:54PM +0300, samuel kihahu wrote:
> On Wed, Dec 17, 2014 at 03:11:19PM +0300, Dan Carpenter wrote:
> > On Wed, Dec 17, 2014 at 02:56:02PM +0300, samuel kihahu wrote:
> > > Replacing obsolete simple_strtoul with kstrtoul.
> > >
> >
> > Nope. That's wrong. Learn how the functions are different beyond just
> > the name.
> Noted, have made corrections to fit the kstrtoul and handle the return
> value.

You have to compile test these things. Really kernel programming is not
a good way to learn how to program. :(

regards,
dan carpenter

2014-12-18 14:48:25

by samuel kihahu

[permalink] [raw]
Subject: Re: [PATCH] staging: speakup: replace simple_strtoul with kstrtoul

On Wed, Dec 17, 2014 at 05:03:22PM +0300, Dan Carpenter wrote:
> On Wed, Dec 17, 2014 at 04:43:54PM +0300, samuel kihahu wrote:
> > On Wed, Dec 17, 2014 at 03:11:19PM +0300, Dan Carpenter wrote:
> > > On Wed, Dec 17, 2014 at 02:56:02PM +0300, samuel kihahu wrote:
> > > > Replacing obsolete simple_strtoul with kstrtoul.
> > > >
> > >
> > > Nope. That's wrong. Learn how the functions are different beyond just
> > > the name.
> > Noted, have made corrections to fit the kstrtoul and handle the return
> > value.
>
> You have to compile test these things. Really kernel programming is not
> a good way to learn how to program. :(
>
> regards,
> dan carpenter
>

Appreciate the feedback, have modified the patch, tested and confirmed
it builds.


Attachments:
(No filename) (753.00 B)
0001-staging-speakup-replace-simple_strtoul-with-kstrtoul.patch (1.03 kB)
Download all attachments

2014-12-18 21:25:32

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH] staging: speakup: replace simple_strtoul with kstrtoul

On Thu, Dec 18, 2014 at 05:48:10PM +0300, samuel kihahu wrote:
> On Wed, Dec 17, 2014 at 05:03:22PM +0300, Dan Carpenter wrote:
> > On Wed, Dec 17, 2014 at 04:43:54PM +0300, samuel kihahu wrote:
> > > On Wed, Dec 17, 2014 at 03:11:19PM +0300, Dan Carpenter wrote:
> > > > On Wed, Dec 17, 2014 at 02:56:02PM +0300, samuel kihahu wrote:
> > > > > Replacing obsolete simple_strtoul with kstrtoul.
> > > > >
> > > >
> > > > Nope. That's wrong. Learn how the functions are different beyond just
> > > > the name.
> > > Noted, have made corrections to fit the kstrtoul and handle the return
> > > value.
> >
> > You have to compile test these things. Really kernel programming is not
> > a good way to learn how to program. :(
> >
> > regards,
> > dan carpenter
> >
>
> Appreciate the feedback, have modified the patch, tested and confirmed
> it builds.

No. It's still really wrong. One of the key differences between
kstrtoul() and simple_strtoul() is that simple_strtoul() gives you a
pointer to the end of the string.

It's actually best to use simple_strtoul() here. Checkpatch.pl is
wrong.

As well the new error handling doesn't work at all.

regards,
dan carpenter