public inbox for speakup@linux-speakup.org
 help / color / mirror / Atom feed
From: Joseph Bisch <joseph.bisch@gmail.com>
To: speakup@linux-speakup.org
Subject: [PATCH] staging: speakup: Change simple_strtoul usage to kstrtoul
Date: Sat, 13 Feb 2016 15:33:52 -0500	[thread overview]
Message-ID: <20160213203351.GA4750@arch_laptop> (raw)

This patch fixes the checkpatch.pl warning:

WARNING: simple_strtoul is obsolete, use kstrtoul instead

Signed-off-by: Joseph Bisch <joseph.bisch@gmail.com>
---
 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

             reply	other threads:[~ UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
 Joseph Bisch [this message]
 ` Chris Brannon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160213203351.GA4750@arch_laptop \
    --to=joseph.bisch@gmail.com \
    --cc=speakup@linux-speakup.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).