From: "J. Bruce Fields" <bfields@fieldses.org>
To: Eldad Zack <eldad@fogrefinery.com>
Cc: Trond Myklebust <Trond.Myklebust@netapp.com>,
Joe Perches <joe@perches.com>,
linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2,resend] sunrpc/cache.h: replace simple_strtoul
Date: Tue, 10 Jul 2012 12:31:20 -0400 [thread overview]
Message-ID: <20120710163119.GB3884@fieldses.org> (raw)
In-Reply-To: <1341603117-13064-2-git-send-email-eldad@fogrefinery.com>
Thanks, applying.
On Fri, Jul 06, 2012 at 09:31:57PM +0200, Eldad Zack wrote:
> This patch replaces the usage of simple_strtoul with kstrtoint in
> get_int(), since the simple_str* family doesn't account for overflow
> and is deprecated.
> Also, in this specific case, the long from strtol is silently converted
> to an int by the caller.
(By the way, one advantage which simple_str* does have is documentation.
Some kerneldoc comments might be helpful for kstrto* as well?)
--b.
>
> As Joe Perches <joe@perches.com> suggested, this patch also removes
> the redundant temporary variable rv, since kstrtoint() will not write to
> anint unless it's successful.
>
> Cc: Joe Perches <joe@perches.com>
> Signed-off-by: Eldad Zack <eldad@fogrefinery.com>
> ---
> Resent to include improvements from Joe Perches and proper changelog as
> J. Bruce Fields kindly pointed out.
> include/linux/sunrpc/cache.h | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h
> index 6def1f6..af42596 100644
> --- a/include/linux/sunrpc/cache.h
> +++ b/include/linux/sunrpc/cache.h
> @@ -217,8 +217,6 @@ extern int qword_get(char **bpp, char *dest, int bufsize);
> static inline int get_int(char **bpp, int *anint)
> {
> char buf[50];
> - char *ep;
> - int rv;
> int len = qword_get(bpp, buf, sizeof(buf));
>
> if (len < 0)
> @@ -226,11 +224,9 @@ static inline int get_int(char **bpp, int *anint)
> if (len == 0)
> return -ENOENT;
>
> - rv = simple_strtol(buf, &ep, 0);
> - if (*ep)
> + if (kstrtoint(buf, 0, anint))
> return -EINVAL;
>
> - *anint = rv;
> return 0;
> }
>
> --
> 1.7.10
>
next prev parent reply other threads:[~2012-07-10 16:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-06 19:31 [PATCH 1/2, resend] sunrpc/cache.h: fix coding style Eldad Zack
2012-07-06 19:31 ` [PATCH 2/2,resend] sunrpc/cache.h: replace simple_strtoul Eldad Zack
2012-07-10 16:31 ` J. Bruce Fields [this message]
2012-07-12 20:54 ` Eldad Zack
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=20120710163119.GB3884@fieldses.org \
--to=bfields@fieldses.org \
--cc=Trond.Myklebust@netapp.com \
--cc=eldad@fogrefinery.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.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
Powered by JetHome