]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Replace unnecessary hex_value() with hex2byte()
authorJouni Malinen <j@w1.fi>
Sat, 28 Dec 2013 14:53:31 +0000 (16:53 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 29 Dec 2013 08:00:32 +0000 (10:00 +0200)
There is no need to maintain two functions for doing
the same type of hex-to-binary conversion.

Signed-hostap: Jouni Malinen <j@w1.fi>

src/wps/httpread.c

index ad4f4a1dcb8a16007b916b2601169fd2dc280070..e2f7c7c639cb6d538f1415c9dbddf2860a1d87d7 100644 (file)
@@ -129,19 +129,6 @@ static int word_eq(char *s1, char *s2)
 }
 
 
-/* convert hex to binary
- * Requires that c have been previously tested true with isxdigit().
- */
-static int hex_value(int c)
-{
-       if (isdigit(c))
-               return c - '0';
-       if (islower(c))
-               return 10 + c - 'a';
-       return 10 + c - 'A';
-}
-
-
 static void httpread_timeout_handler(void *eloop_data, void *user_ctx);
 
 /* httpread_destroy -- if h is non-NULL, clean up
@@ -295,8 +282,7 @@ static int httpread_hdr_analyze(struct httpread *h)
                        int c = *rawuri;
                        if (c == '%' &&
                            isxdigit(rawuri[1]) && isxdigit(rawuri[2])) {
-                               *uri++ = (hex_value(rawuri[1]) << 4) |
-                                       hex_value(rawuri[2]);
+                               *uri++ = hex2byte(rawuri + 1);
                                rawuri += 3;
                        } else {
                                *uri++ = c;