Commit 60b00ad8 authored by Neil Brown's avatar Neil Brown Committed by Linus Torvalds

[PATCH] kNFSd: get_int and get_expiry to help in parsing.

parent 5ce8b167
......@@ -275,4 +275,28 @@ extern void add_word(char **bpp, int *lp, char *str);
extern void add_hex(char **bpp, int *lp, char *buf, int blen);
extern int get_word(char **bpp, char *dest, int bufsize);
static inline int get_int(char **bpp, int *anint)
{
char buf[50];
char *ep;
int rv;
int len = get_word(bpp, buf, 50);
if (len < 0) return -EINVAL;
if (len ==0) return -ENOENT;
rv = simple_strtol(buf, &ep, 0);
if (*ep) return -EINVAL;
*anint = rv;
return 0;
}
static inline time_t get_expiry(char **bpp)
{
int rv;
if (get_int(bpp, &rv))
return 0;
if (rv < 0)
return 0;
return rv;
}
#endif /* _LINUX_SUNRPC_CACHE_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment