All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhang Zhen <zhenzhang.zhang@huawei.com>
To: <adrian.hunter@intel.com>, <dedekind1@gmail.com>
Cc: linux-mtd@lists.infradead.org
Subject: [PATCH] ubifs: replace simple_strtoul() with kstrtoul()
Date: Mon, 19 May 2014 11:26:33 +0800	[thread overview]
Message-ID: <537979E9.3060209@huawei.com> (raw)
In-Reply-To: <1400469756-18212-1-git-send-email-zhenzhang.zhang@huawei.com>

use the newer and more pleasant kstrtoul() to replace simple_strtoul(),
because simple_strtoul() is marked for obsoletion.

Signed-off-by: Zhang Zhen <zhenzhang.zhang@huawei.com>
---
 fs/ubifs/super.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index a81c7b5..a30f297 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -1905,6 +1905,7 @@ static struct ubi_volume_desc *open_ubi(const char *name, int mode)
 	struct ubi_volume_desc *ubi;
 	int dev, vol;
 	char *endptr;
+	int ret;

 	/* First, try to open using the device node path method */
 	ubi = ubi_open_volume_path(name, mode);
@@ -1922,7 +1923,10 @@ static struct ubi_volume_desc *open_ubi(const char *name, int mode)
 	if (!isdigit(name[3]))
 		return ERR_PTR(-EINVAL);

-	dev = simple_strtoul(name + 3, &endptr, 0);
+	endptr = (char *)name + 3;
+	ret = kstrtoul(endptr, 0, (unsigned long *)&dev);
+	if (ret)
+		return ERR_PTR(-EINVAL);

 	/* ubiY method */
 	if (*endptr == '\0')
@@ -1930,7 +1934,10 @@ static struct ubi_volume_desc *open_ubi(const char *name, int mode)

 	/* ubiX_Y method */
 	if (*endptr == '_' && isdigit(endptr[1])) {
-		vol = simple_strtoul(endptr + 1, &endptr, 0);
+		endptr = endptr + 1;
+		ret = kstrtoul(endptr, 0, (unsigned long *)&vol);
+		if (ret)
+			return ERR_PTR(-EINVAL);
 		if (*endptr != '\0')
 			return ERR_PTR(-EINVAL);
 		return ubi_open_volume(dev, vol, mode);
-- 
1.8.1.2


.

       reply	other threads:[~2014-05-19  3:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1400469756-18212-1-git-send-email-zhenzhang.zhang@huawei.com>
2014-05-19  3:26 ` Zhang Zhen [this message]
2014-05-19  9:13   ` [PATCH] ubifs: replace simple_strtoul() with kstrtoul() Geert Uytterhoeven
2014-05-19  9:49     ` Zhang Zhen
2014-05-20  6:53       ` Geert Uytterhoeven
2014-05-20  6:57         ` Geert Uytterhoeven
2014-05-20  8:14           ` Zhang Zhen

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=537979E9.3060209@huawei.com \
    --to=zhenzhang.zhang@huawei.com \
    --cc=adrian.hunter@intel.com \
    --cc=dedekind1@gmail.com \
    --cc=linux-mtd@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.