diff options
author | Eldad Zack <eldad@fogrefinery.com> | 2012-07-06 15:31:57 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2012-07-11 16:08:00 -0400 |
commit | bbf43dc888833ac0539e437dbaeb28bfd4fbab9f (patch) | |
tree | 3e75d68f3811f438c451281e30ec5ad16b555c58 | |
parent | d9c2ede63c74048dfddbb129c59ac01176b0ab71 (diff) |
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: Eldad Zack <eldad@fogrefinery.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
-rw-r--r-- | include/linux/sunrpc/cache.h | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h index 6def1f6cc269..af42596a82f9 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); | |||
217 | static inline int get_int(char **bpp, int *anint) | 217 | static inline int get_int(char **bpp, int *anint) |
218 | { | 218 | { |
219 | char buf[50]; | 219 | char buf[50]; |
220 | char *ep; | ||
221 | int rv; | ||
222 | int len = qword_get(bpp, buf, sizeof(buf)); | 220 | int len = qword_get(bpp, buf, sizeof(buf)); |
223 | 221 | ||
224 | if (len < 0) | 222 | if (len < 0) |
@@ -226,11 +224,9 @@ static inline int get_int(char **bpp, int *anint) | |||
226 | if (len == 0) | 224 | if (len == 0) |
227 | return -ENOENT; | 225 | return -ENOENT; |
228 | 226 | ||
229 | rv = simple_strtol(buf, &ep, 0); | 227 | if (kstrtoint(buf, 0, anint)) |
230 | if (*ep) | ||
231 | return -EINVAL; | 228 | return -EINVAL; |
232 | 229 | ||
233 | *anint = rv; | ||
234 | return 0; | 230 | return 0; |
235 | } | 231 | } |
236 | 232 | ||