Skip to contentSkip to conversation

staging: speakup: replace simple_strtoul with kstrtou8

PATCH In review Marcin Ciupak 2 participants 3 messages Mar 2, 2017 – Mar 3, 2017 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: speakup: replace simple_strtoul with kstrtou8

Replace simple_strtoul with kstrtou8.
simple_strtoul is marked for obsoletion.

---
 drivers/staging/speakup/varhandlers.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/speakup/varhandlers.c +2 -3
index cc984196020f..c219db745865 100644
@@ -323,11 +323,10 @@ char *spk_strlwr(char *s)
 
 char *spk_s2uchar(char *start, char *dest)
 {
-	int val;
+	int ret;
 
-	val = simple_strtoul(skip_spaces(start), &start, 10);
+	ret = kstrtou8(skip_spaces(start), 10, dest);
 	if (*start == ',')
 		start++;
-	*dest = (u_char)val;
 	return start;
 }
Signature · 1 line
2.11.1
#1 lore raw

drivers/staging/speakup/varhandlers.c char *spk_strlwr(char *s) · line 328

Quoted 5 lines · Marcin Ciupak, on jeu. 02 mars 2017 15:28:23 +0100, wrote:
drivers/staging/speakup/varhandlers.c +2 -2
-	int val;
+	int ret;
 
-	val = simple_strtoul(skip_spaces(start), &start, 10);
+	ret = kstrtou8(skip_spaces(start), 10, dest);

This is not the same, you need to have start properly move, since it's used below:

drivers/staging/speakup/varhandlers.c char *spk_strlwr(char *s) · line 331

Quoted 4 lines
drivers/staging/speakup/varhandlers.c +0 -1
 	if (*start == ',')
 		start++;
-	*dest = (u_char)val;
 	return start;

Samuel

#2 lore raw
Quoted 10 lines · Samuel Thibault

drivers/staging/speakup/varhandlers.c char *spk_strlwr(char *s) · line 328

Quoted 5 lines · Marcin Ciupak, on jeu. 02 mars 2017 15:28:23 +0100, wrote:
drivers/staging/speakup/varhandlers.c +2 -2
-	int val;
+	int ret;
 
-	val = simple_strtoul(skip_spaces(start), &start, 10);
+	ret = kstrtou8(skip_spaces(start), 10, dest);

This is not the same, you need to have start properly move, since it's used below:

Quoted 6 lines

drivers/staging/speakup/varhandlers.c char *spk_strlwr(char *s) · line 331

Quoted 4 lines
drivers/staging/speakup/varhandlers.c +0 -1
 	if (*start == ',')
 		start++;
-	*dest = (u_char)val;
 	return start;

Samuel

You are right, start is not updated by kstrtou8 like it is by simple_strtoul.

If I understand it correctly simple_strtoul cannot be replaced by kstrtou8 here.

Please discard this patch.

Marcin