Patchwork [2/3] sunrpc/cache: don't use custom hex_to_bin() converter

login
register
mail settings
Submitter Andy Shevchenko
Date Sept. 20, 2010, 11:27 p.m.
Message ID <caff03788e07cab152f750489ea08d43bc13efed.1285024850.git.andy.shevchenko@gmail.com>
Download mbox | patch
Permalink /patch/65267/
State Superseded
Delegated to: David Miller
Headers show

Comments

Andy Shevchenko - Sept. 20, 2010, 11:27 p.m.
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: linux-nfs@vger.kernel.org
---
 net/sunrpc/cache.c |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

Patch

diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index 5b7b56f..c944a24 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -1171,13 +1171,19 @@  int qword_get(char **bpp, char *dest, int bufsize)
 	if (bp[0] == '\\' && bp[1] == 'x') {
 		/* HEX STRING */
 		bp += 2;
-		while (isxdigit(bp[0]) && isxdigit(bp[1]) && len < bufsize) {
-			int byte = isdigit(*bp) ? *bp-'0' : toupper(*bp)-'A'+10;
-			bp++;
-			byte <<= 4;
-			byte |= isdigit(*bp) ? *bp-'0' : toupper(*bp)-'A'+10;
-			*dest++ = byte;
-			bp++;
+		while (len < bufsize) {
+			int h, l;
+
+			h = hex_to_bin(bp[0]);
+			if (h < 0)
+				break;
+
+			l = hex_to_bin(bp[1]);
+			if (l < 0)
+				break;
+
+			*dest++ = (h << 4) | l;
+			bp += 2;
 			len++;
 		}
 	} else {