Skip to content

Commit bbf43dc

Browse files
eldadJ. Bruce Fields
authored andcommitted
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>
1 parent d9c2ede commit bbf43dc

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

‎include/linux/sunrpc/cache.h‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,20 +217,16 @@ extern int qword_get(char **bpp, char *dest, int bufsize);
217217
static inline int get_int(char **bpp, int *anint)
218218
{
219219
char buf[50];
220-
char *ep;
221-
int rv;
222220
int len = qword_get(bpp, buf, sizeof(buf));
223221

224222
if (len < 0)
225223
return -EINVAL;
226224
if (len == 0)
227225
return -ENOENT;
228226

229-
rv = simple_strtol(buf, &ep, 0);
230-
if (*ep)
227+
if (kstrtoint(buf, 0, anint))
231228
return -EINVAL;
232229

233-
*anint = rv;
234230
return 0;
235231
}
236232

0 commit comments

Comments
 (0)