From: Volker Lendecke Date: Tue, 10 Sep 2024 06:46:30 +0000 (+0200) Subject: lib: Simplify nybble_to_hex_* X-Git-Tag: tdb-1.4.13~552 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=7c4d1f9de146c3e4fa97a2200ab98d0df9d8fdfd;p=thirdparty%2Fsamba.git lib: Simplify nybble_to_hex_* Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- diff --git a/lib/util/samba_util.h b/lib/util/samba_util.h index a38cc8a92f2..3994f8373c5 100644 --- a/lib/util/samba_util.h +++ b/lib/util/samba_util.h @@ -652,54 +652,12 @@ void samba_tevent_set_debug(struct tevent_context *ev, const char *name); static inline char nybble_to_hex_lower(uint8_t val) { - uint8_t nybble = val & 0xf; - - switch (nybble) { - case 0x0: case 0x1: case 0x2: case 0x3: case 0x4: - case 0x5: case 0x6: case 0x7: case 0x8: case 0x9: - return '0' + nybble; - case 0xa: - return 'a'; - case 0xb: - return 'b'; - case 0xc: - return 'c'; - case 0xd: - return 'd'; - case 0xe: - return 'e'; - case 0xf: - return 'f'; - } - - /* unreachable */ - return '\0'; + return hexchars_lower[val & 0xf]; } static inline char nybble_to_hex_upper(uint8_t val) { - uint8_t nybble = val & 0xf; - - switch (nybble) { - case 0x0: case 0x1: case 0x2: case 0x3: case 0x4: - case 0x5: case 0x6: case 0x7: case 0x8: case 0x9: - return '0' + nybble; - case 0xa: - return 'A'; - case 0xb: - return 'B'; - case 0xc: - return 'C'; - case 0xd: - return 'D'; - case 0xe: - return 'E'; - case 0xf: - return 'F'; - } - - /* unreachable */ - return '\0'; + return hexchars_upper[val & 0xf]; } #endif /* _SAMBA_UTIL_H_ */