sunrpc/cache: don't use custom hex_to_bin() converter
authorAndy Shevchenko <andy.shevchenko@gmail.com>
Tue, 21 Sep 2010 06:40:25 +0000 (09:40 +0300)
committerJ. Bruce Fields <bfields@redhat.com>
Wed, 22 Sep 2010 02:45:07 +0000 (22:45 -0400)
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: linux-nfs@vger.kernel.org
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
net/sunrpc/cache.c

index 2a840519405633ec2ee69f8d9c825e64c7eba406..ac2c6e6abe65d5c7c9d49451c8b830b518b8defc 100644 (file)
@@ -1179,13 +1179,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 {