Skip to content

Commit

Permalink
sunrpc/cache.h: replace simple_strtoul
Browse files Browse the repository at this point in the history
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: Eldad Zack <eldad@fogrefinery.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
  • Loading branch information
Eldad Zack authored and J. Bruce Fields committed Jul 11, 2012
1 parent d9c2ede commit bbf43dc
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions include/linux/sunrpc/cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,20 +217,16 @@ 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)
return -EINVAL;
if (len == 0)
return -ENOENT;

rv = simple_strtol(buf, &ep, 0);
if (*ep)
if (kstrtoint(buf, 0, anint))
return -EINVAL;

*anint = rv;
return 0;
}

Expand Down

0 comments on commit bbf43dc

Please sign in to comment.