提交 bbf43dc8 编写于 作者: E Eldad Zack 提交者: J. Bruce Fields

sunrpc/cache.h: replace simple_strtoul

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.

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: NEldad Zack <eldad@fogrefinery.com>
Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
上级 d9c2ede6
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册