[PATCH] staging: speakup: Change simple_strtoul usage to kstrtoul

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch fixes the checkpatch.pl warning:

WARNING: simple_strtoul is obsolete, use kstrtoul instead

Signed-off-by: Joseph Bisch <joseph.bisch@xxxxxxxxx>
---
 drivers/staging/speakup/kobjects.c    | 12 ++++++++++--
 drivers/staging/speakup/main.c        |  6 +++++-
 drivers/staging/speakup/varhandlers.c |  6 +++++-
 3 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/speakup/kobjects.c b/drivers/staging/speakup/kobjects.c
index fdfeb42..8eb4fdf 100644
--- a/drivers/staging/speakup/kobjects.c
+++ b/drivers/staging/speakup/kobjects.c
@@ -126,6 +126,7 @@ static ssize_t chars_chartab_store(struct kobject *kobj,
 	int do_characters = !strcmp(attr->attr.name, "characters");
 	size_t desc_length = 0;
 	int i;
+	int err;
 
 	spin_lock_irqsave(&speakup_info.spinlock, flags);
 	while (cp < end) {
@@ -153,7 +154,10 @@ static ssize_t chars_chartab_store(struct kobject *kobj,
 			continue;
 		}
 
-		index = simple_strtoul(cp, &temp, 10);
+		temp = cp;
+		err = kstrtoul(temp, 10, &index);
+		if (err)
+			return err;
 		if (index > 255) {
 			rejected++;
 			cp = linefeed + 1;
@@ -754,6 +758,7 @@ static ssize_t message_store_helper(const char *buf, size_t count,
 	int used = 0;
 	int rejected = 0;
 	int reset = 0;
+	int err;
 	enum msg_index_t firstmessage = group->start;
 	enum msg_index_t lastmessage = group->end;
 	enum msg_index_t curmessage;
@@ -783,7 +788,10 @@ static ssize_t message_store_helper(const char *buf, size_t count,
 			continue;
 		}
 
-		index = simple_strtoul(cp, &temp, 10);
+		temp = cp;
+		err = kstrtoul(temp, 10, &index);
+		if (err)
+			return err;
 
 		while ((temp < linefeed) && (*temp == ' ' || *temp == '\t'))
 			temp++;
diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c
index 30cf973..9add4ab 100644
--- a/drivers/staging/speakup/main.c
+++ b/drivers/staging/speakup/main.c
@@ -1904,6 +1904,7 @@ static int handle_goto(struct vc_data *vc, u_char type, u_char ch, u_short key)
 	static int num;
 	int maxlen;
 	char *cp;
+	int ret;
 
 	if (type == KT_SPKUP && ch == SPEAKUP_GOTO)
 		goto do_goto;
@@ -1940,7 +1941,10 @@ oops:
 		return 1;
 	}
 
-	goto_pos = simple_strtoul(goto_buf, &cp, 10);
+	cp = goto_buf;
+	ret = kstrtoul(cp, 10, &goto_pos);
+	if (ret)
+		return ret;
 
 	if (*cp == 'x') {
 		if (*goto_buf < '0')
diff --git a/drivers/staging/speakup/varhandlers.c b/drivers/staging/speakup/varhandlers.c
index ab4fe8d..7a640e3 100644
--- a/drivers/staging/speakup/varhandlers.c
+++ b/drivers/staging/speakup/varhandlers.c
@@ -324,8 +324,12 @@ char *spk_strlwr(char *s)
 char *spk_s2uchar(char *start, char *dest)
 {
 	int val;
+	int ret;
 
-	val = simple_strtoul(skip_spaces(start), &start, 10);
+	start = skip_spaces(start);
+	ret = kstrtoul(start, 10, (unsigned long *)&val);
+	if (ret)
+		return NULL;
 	if (*start == ',')
 		start++;
 	*dest = (u_char)val;
-- 
2.7.0

This is my first patch to the Linux kernel, so I appreciate any information
about how it can be improved. I tested this patch with espeakup and it appears
to not break anything.

Also, I was unsure if I should notify anyone else or any other mailing lists,
so let me know if I should forward this email anywhere.

Joseph
_______________________________________________
Speakup mailing list
Speakup@xxxxxxxxxxxxxxxxx
http://linux-speakup.org/cgi-bin/mailman/listinfo/speakup




[Index of Archives]     [Linux for the Blind]     [Fedora Discussioin]     [Linux Kernel]     [Yosemite News]     [Big List of Linux Books]
  Powered by Linux