sunrpc/cache.h: fix coding style
Subsystems (2)
PATCH 1/2 sunrpc/cache.h: fix coding style
Neaten code style in get_int()
--- include/linux/sunrpc/cache.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
include/linux/sunrpc/cache.h +9 -3
@@ -220,10 +220,16 @@ static inline int get_int(char **bpp, int *anint)char *ep;int rv;int len =qword_get (bpp, buf,50 ); -if (len <0 )return -EINVAL ; -if (len ==0 )return -ENOENT ; + +if (len <0 ) +return -EINVAL ; +if (len ==0 ) +return -ENOENT ; + rv =simple_strtol (buf, &ep,0 ); -if (*ep)return -EINVAL ; +if (*ep) +return -EINVAL ; + *anint = rv;return 0 ; }
Signature · 1 line
1.7.10
PATCH 2/2 sunrpc/cache.h: replace simple_strtoul
This patch replaces the usage of simple_strtoul with kstrtoint in get_int().
--- include/linux/sunrpc/cache.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
include/linux/sunrpc/cache.h +3 -3
@@ -217,7 +217,7 @@ extern int qword_get(char **bpp, char *dest, int bufsize);static inline int get_int (char **bpp,int *anint) {char buf[50 ]; -char *ep; +ssize_t ret;int rv;int len =qword_get (bpp, buf,50 );
@@ -226,8 +226,8 @@ static inline int get_int(char **bpp, int *anint)if (len ==0 )return -ENOENT ; - rv =simple_strtol (buf, &ep,0 ); -if (*ep) + ret =kstrtoint (buf,0 , &rv); +if (ret)return -EINVAL ; *anint = rv;
Signature · 1 line
1.7.10
Re: [PATCH 2/2] sunrpc/cache.h: replace simple_strtoul
Quoted 2 lines · Eldad Zack
This patch replaces the usage of
simple_strtoulwith kstrtoint inget_int().
Just some trivia:
include/linux/sunrpc/cache.h
Quoted 1 line
include/linux/sunrpc/cache.h +0
-0
[]
include/linux/sunrpc/cache.h extern int qword_get(char **bpp, char *dest, int bufsize); · line 222
Quoted 8 lines
include/linux/sunrpc/cache.h +1
-1@@ -217,7 +217,7 @@ extern int qword_get(char **bpp, char *dest, int bufsize);static inline int get_int (char **bpp,int *anint) {char buf[50 ]; -char *ep; +ssize_t ret;int rv;int len =qword_get (bpp, buf,50 );
This would be nicer as
int len = qword_get(bpp, buf, sizeof(buf));
include/linux/sunrpc/cache.h static inline int get_int(char **bpp, int *anint) · line 233
Quoted 11 lines
include/linux/sunrpc/cache.h +2
-2@@ -226,8 +226,8 @@ static inline int get_int(char **bpp, int *anint)if (len ==0 )return -ENOENT ; - rv =simple_strtol (buf, &ep,0 ); -if (*ep) + ret =kstrtoint (buf,0 , &rv); +if (ret)return -EINVAL ; *anint = rv;
ret and rv aren't useful anymore.
Perhaps:
if (kstrtoint(buf, 0, anint)) return -EINVAL; return 0;
Re: [PATCH 2/2] sunrpc/cache.h: replace simple_strtoul
Quoted 7 lines · Joe Perches
Quoted 4 lines · Eldad Zack
This patch replaces the usage of
simple_strtoulwith kstrtoint inget_int().int len =
qword_get(bpp, buf, 50);This would be nicer as
int len = qword_get(bpp, buf, sizeof(buf));
I agree, thanks!
Quoted 8 lines
include/linux/sunrpc/cache.h static inline int get_int(char **bpp, int *anint) · line 230
Quoted 6 lines
include/linux/sunrpc/cache.h +2
-0@@ -226,8 +226,8 @@ static inline int get_int(char **bpp, int *anint) + ret =kstrtoint (buf,0 , &rv); +if (ret)return -EINVAL ; *anint = rv;ret and rv aren't useful anymore.
Quoted 6 lines
Perhaps:
if (kstrtoint(buf, 0, anint)) return -EINVAL; return 0;
Yes, that works better, since kstrtoint() will not write to anint unless it's successful, so the whole business with rv is indeed redundant.
Looks much neater now thanks to your comments - I will resend it a bit later. Should I add you as Signed-off-by?
Eldad
Re: [PATCH 2/2] sunrpc/cache.h: replace simple_strtoul
In reply to Eldad ZackQuoted 2 lines · Eldad Zack
This patch replaces the usage of
simple_strtoulwith kstrtoint inget_int().
Why?
--b.
Quoted 33 lines
Signed-off-by Eldad Zack <[email protected]>--- include/linux/sunrpc/cache.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)include/linux/sunrpc/cache.h +3
-3@@ -217,7 +217,7 @@ extern int qword_get(char **bpp, char *dest, int bufsize);static inline int get_int (char **bpp,int *anint) {char buf[50 ]; -char *ep; +ssize_t ret;int rv;int len =qword_get (bpp, buf,50 );@@ -226,8 +226,8 @@ static inline int get_int(char **bpp, int *anint)if (len ==0 )return -ENOENT ; - rv =simple_strtol (buf, &ep,0 ); -if (*ep) + ret =kstrtoint (buf,0 , &rv); +if (ret)return -EINVAL ; *anint = rv;Signature · 1 line
1.7.10
Re: [PATCH 2/2] sunrpc/cache.h: replace simple_strtoul
Quoted 5 lines · J. Bruce Fields
Quoted 2 lines · Eldad Zack
This patch replaces the usage of
simple_strtoulwith kstrtoint inget_int().Why?
Since the simple_str* family don't account for overflow and AFAIK deprecated. Also, in this specific case, the long from strtol is silently converted to an int by the caller.
Eldad
Re: [PATCH 2/2] sunrpc/cache.h: replace simple_strtoul
Quoted 11 lines · Eldad Zack
Quoted 5 lines · J. Bruce Fields
Quoted 2 lines · Eldad Zack
This patch replaces the usage of
simple_strtoulwith kstrtoint inget_int().Why?
Since the simple_str* family don't account for overflow and AFAIK deprecated. Also, in this specific case, the long from strtol is silently converted to an int by the caller.
OK, thanks. Please use that as the changelog when you resend. ("This patch replaces..." tells me nothing I couldn't figure out from looking at the patch.)
--b.
Re: [PATCH 2/2] sunrpc/cache.h: replace simple_strtoul
Quoted 9 lines · J. Bruce Fields
Quoted 8 lines · Eldad Zack
Quoted 5 lines · J. Bruce Fields
Quoted 2 lines · Eldad Zack
This patch replaces the usage of
simple_strtoulwith kstrtoint inget_int().Why?
Quoted 7 lines
Quoted 3 lines
Since the simple_str* family don't account for overflow and AFAIK deprecated. Also, in this specific case, the long from strtol is silently converted to an int by the caller.
OK, thanks. Please use that as the changelog when you resend. ("This patch replaces..." tells me nothing I couldn't figure out from looking at the patch.)
Will do, sorry about that.
Eldad