lib: Simplify _hexcharval
authorVolker Lendecke <vl@samba.org>
Mon, 19 Feb 2024 12:15:55 +0000 (13:15 +0100)
committerVolker Lendecke <vl@samba.org>
Tue, 12 Mar 2024 13:31:31 +0000 (13:31 +0000)
Saves a few bytes and conditional jumps

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/replace/replace.h

index a6a2b40777f3c932ca6839a08a31998cc295acb1..537e61e1e4888ed0b0327509ecda6d8b677944aa 100644 (file)
@@ -1079,7 +1079,7 @@ static inline bool uid_wrapper_enabled(void)
 static inline bool _hexcharval(char c, uint8_t *val)
 {
        if ((c >= '0') && (c <= '9')) { *val = c - '0';      return true; }
-       if ((c >= 'a') && (c <= 'f')) { *val = c - 'a' + 10; return true; }
+        c &= 0xDF; /* map lower to upper case -- thanks libnfs :-) */
        if ((c >= 'A') && (c <= 'F')) { *val = c - 'A' + 10; return true; }
        return false;
 }