From 4803e85d7d5ef8e259db4d7473b7034852bea2c3 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 10 Sep 2024 09:55:36 +0200 Subject: [PATCH] vfs: Simplify capencode() with nybble_to_hex_lower() Signed-off-by: Volker Lendecke Reviewed-by: Noel Power --- source3/modules/vfs_cap.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/source3/modules/vfs_cap.c b/source3/modules/vfs_cap.c index 83792d59fb5..8d5eb6fc91e 100644 --- a/source3/modules/vfs_cap.c +++ b/source3/modules/vfs_cap.c @@ -902,7 +902,6 @@ NTSTATUS vfs_cap_init(TALLOC_CTX *ctx) /* For CAP functions */ #define hex_tag ':' #define hex2bin(c) hex2bin_table[(unsigned char)(c)] -#define bin2hex(c) bin2hex_table[(unsigned char)(c)] #define is_hex(s) ((s)[0] == hex_tag) static unsigned char hex2bin_table[256] = { @@ -925,7 +924,6 @@ static unsigned char hex2bin_table[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xe0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* 0xf0 */ }; -static unsigned char bin2hex_table[256] = "0123456789abcdef"; /******************************************************************* original code -> ":xx" - CAP format @@ -956,8 +954,8 @@ static char *capencode(TALLOC_CTX *ctx, const char *from) /* buffer husoku error */ if ((unsigned char)*from >= 0x80) { *out++ = hex_tag; - *out++ = bin2hex (((*from)>>4)&0x0f); - *out++ = bin2hex ((*from)&0x0f); + *out++ = nybble_to_hex_lower(((*from) >> 4)); + *out++ = nybble_to_hex_lower(*from); from++; } else { *out++ = *from++; -- 2.47.2