Commit bbf43dc888833ac0539e437dbaeb28bfd4fbab9f
Committed by
J. Bruce Fields
1 parent
d9c2ede63c
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>
Showing 1 changed file with 1 additions and 5 deletions Side-by-side Diff
include/linux/sunrpc/cache.h
... | ... | @@ -217,8 +217,6 @@ |
217 | 217 | static inline int get_int(char **bpp, int *anint) |
218 | 218 | { |
219 | 219 | char buf[50]; |
220 | - char *ep; | |
221 | - int rv; | |
222 | 220 | int len = qword_get(bpp, buf, sizeof(buf)); |
223 | 221 | |
224 | 222 | if (len < 0) |
225 | 223 | |
... | ... | @@ -226,11 +224,9 @@ |
226 | 224 | if (len == 0) |
227 | 225 | return -ENOENT; |
228 | 226 | |
229 | - rv = simple_strtol(buf, &ep, 0); | |
230 | - if (*ep) | |
227 | + if (kstrtoint(buf, 0, anint)) | |
231 | 228 | return -EINVAL; |
232 | 229 | |
233 | - *anint = rv; | |
234 | 230 | return 0; |
235 | 231 | } |
236 | 232 |