lib, net: make isodigit public and use it
Subsystems (6)
PATCH 1/1 lib, net: make isodigit public and use it
There are at least two users of isodigit. Let's make it a public function of ctype.h.
--- include/linux/ctype.h | 6 ++++++ lib/dynamic_debug.c | 1 - net/sunrpc/cache.c | 1 - 3 files changed, 6 insertions(+), 2 deletions(-)
include/linux/ctype.h +6 -0
@@ -61,4 +61,10 @@ static inline char _tolower(const char c) return c | 0x20; } +/* Fast check for octal digit */ +static inline int isodigit (const char c) +{ +return c >='0' && c <='7' ; +} +#endif
lib/dynamic_debug.c +0 -1
@@ -281,7 +281,6 @@ static inline int parse_lineno(const char *str, unsigned int *val)* allow the user to express a query which matches a format * containing embedded spaces. */ -#define isodigit (c) ((c) >= '0' && (c) <= '7')static char *unescape (char *str) {char *in = str;
net/sunrpc/cache.c +0 -1
@@ -1210,7 +1210,6 @@ EXPORT_SYMBOL_GPL(sunrpc_cache_pipe_upcall);* key and content are both parsed by cache */ -#define isodigit (c) (isdigit(c) && c <= '7')int qword_get (char **bpp,char *dest,int bufsize) {/* return bytes copied, or -1 on error */
Signature · 1 line
1.8.2.rc0.22.gb3600c3
what about #define isoctal(c) (((c) & ~7) ?
Quoted 59 lines · Andy Shevchenko
There are at least two users of isodigit. Let's make it a public function of
ctype.h.Signed-off-by Andy Shevchenko <[email protected]>--- include/linux/ctype.h | 6 ++++++ lib/dynamic_debug.c | 1 - net/sunrpc/cache.c | 1 - 3 files changed, 6 insertions(+), 2 deletions(-)include/linux/ctype.h +6
-0@@ -61,4 +61,10 @@ static inline char _tolower(const char c) return c | 0x20; } +/* Fast check for octal digit */ +static inline int isodigit (const char c) +{ +return c >='0' && c <='7' ; +} +#endif lib/dynamic_debug.c +0
-1@@ -281,7 +281,6 @@ static inline int parse_lineno(const char *str, unsignedint *val) * allow the user to express a query which matches a format * containing embedded spaces. */ -#define isodigit (c) ((c) >= '0' && (c) <= '7')static char *unescape (char *str) {lib/dynamic_debug.c +0
-0char *in = str;net/sunrpc/cache.c +0
-2@@ -1210,7 +1210,6 @@ EXPORT_SYMBOL_GPL(sunrpc_cache_pipe_upcall);* key and content are both parsed by cache */ -#define isodigit (c) (isdigit(c) && c <= '7')int qword_get (char **bpp,char *dest,int bufsize) {/* return bytes copied, or -1 on error */ --1.8.2.rc0.22.gb3600c3
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 1 line · Denis Kirjanov
what about #define isoctal(c) (((c) & ~7) ?
Few reasons why not:
- the name isodigit is used already
- above name is more logical to existing isdigit & isxdigit
- macro is usually worse than inline function
- your implementation is not strict to octal digits
Quoted 61 lines · Andy Shevchenko
Quoted 59 lines
There are at least two users of isodigit. Let's make it a public function of
ctype.h.Signed-off-by Andy Shevchenko <[email protected]>--- include/linux/ctype.h | 6 ++++++ lib/dynamic_debug.c | 1 - net/sunrpc/cache.c | 1 - 3 files changed, 6 insertions(+), 2 deletions(-)include/linux/ctype.h +6
-0@@ -61,4 +61,10 @@ static inline char _tolower(const char c) return c | 0x20; } +/* Fast check for octal digit */ +static inline int isodigit (const char c) +{ +return c >='0' && c <='7' ; +} +#endif lib/dynamic_debug.c +0
-1@@ -281,7 +281,6 @@ static inline int parse_lineno(const char *str, unsignedint *val) * allow the user to express a query which matches a format * containing embedded spaces. */ -#define isodigit (c) ((c) >= '0' && (c) <= '7')static char *unescape (char *str) {lib/dynamic_debug.c +0
-0char *in = str;net/sunrpc/cache.c +0
-2@@ -1210,7 +1210,6 @@ EXPORT_SYMBOL_GPL(sunrpc_cache_pipe_upcall);* key and content are both parsed by cache */ -#define isodigit (c) (isdigit(c) && c <= '7')int qword_get (char **bpp,char *dest,int bufsize) {/* return bytes copied, or -1 on error */ --1.8.2.rc0.22.gb3600c3
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Quoted 1 line
what about #define isoctal(c) (((c) & ~7) ?
I presume you meant (((c) & ~7) == '0')
Actually the compiler will convert:
c >= '0' && c <= '7'; into (unsigned)(c - '0') <= '7' - '0';
so it makes no significant difference.
Whether adding it to ctype.h is a good idea is a different problem for the C standards people.
David