From: Zhang Zhen <zhenzhang.zhang@huawei.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Hu Jianyang <hujianyang@huawei.com>,
MTD Maling List <linux-mtd@lists.infradead.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Artem Bityutskiy <dedekind1@gmail.com>
Subject: Re: [PATCH v3] UBIFS: replace simple_strtoul() with kstrtoint()
Date: Wed, 21 May 2014 17:00:39 +0800 [thread overview]
Message-ID: <537C6B37.8090508@huawei.com> (raw)
In-Reply-To: <CAMuHMdVqimC046YXDVmPt5+8_bphy_gn963AMo-_bMtgobjMKA@mail.gmail.com>
On 2014/5/21 14:30, Geert Uytterhoeven wrote:
> On Wed, May 21, 2014 at 5:00 AM, Zhang Zhen <zhenzhang.zhang@huawei.com> wrote:
>> @@ -1922,7 +1922,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 = name + 3;
>
> As Adrian pointed out, endptr is used later, and it must point to the
> character after the parsed number.
>
Okay, it appears kstrtoint is not suitable to replace the simple_strtoul here.
The first argument of kstrto* can not point to the character after the parsed number.
>> + ret = kstrtoint(endptr, 0, &dev);
>> + if (ret)
>> + return ERR_PTR(-EINVAL);
>>
>> /* ubiY method */
>> if (*endptr == '\0')
>> @@ -1930,7 +1933,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 = kstrtoint(endptr, 0, &vol);
>> + if (ret)
>> + return ERR_PTR(-EINVAL);
>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
> -- Linus Torvalds
>
>
prev parent reply other threads:[~2014-05-21 9:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1400641191-27877-1-git-send-email-zhenzhang.zhang@huawei.com>
2014-05-21 3:00 ` [PATCH v3] UBIFS: replace simple_strtoul() with kstrtoint() Zhang Zhen
2014-05-21 6:30 ` Geert Uytterhoeven
2014-05-21 9:00 ` Zhang Zhen [this message]
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=537C6B37.8090508@huawei.com \
--to=zhenzhang.zhang@huawei.com \
--cc=adrian.hunter@intel.com \
--cc=dedekind1@gmail.com \
--cc=geert@linux-m68k.org \
--cc=hujianyang@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox