Skip to contentSkip to conversation

net/sunrpc/cache: simplify code by using hex_pack_byte()

PATCH In review Andy Shevchenko 2 participants 2 messages Dec 12, 2013

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/sunrpc/cache: simplify code by using hex_pack_byte()

hex_pack_byte() is a fast way to convert a byte in its ASCII representation. We may use it instead of custom approach.

---
 net/sunrpc/cache.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
net/sunrpc/cache.c +1 -3
index a72de07..0877db0 100644
@@ -1111,9 +1111,7 @@ void qword_addhex(char **bpp, int *lp, char *buf, int blen)
 		*bp++ = 'x';
 		len -= 2;
 		while (blen && len >= 2) {
-			unsigned char c = *buf++;
-			*bp++ = '0' + ((c&0xf0)>>4) + (c>=0xa0)*('a'-'9'-1);
-			*bp++ = '0' + (c&0x0f) + ((c&0x0f)>=0x0a)*('a'-'9'-1);
+			bp = hex_byte_pack(bp, *buf++);
 			len -= 2;
 			blen--;
 		}
Signature · 6 lines
1.8.4.4

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw
Quoted 2 lines · Andy Shevchenko

hex_pack_byte() is a fast way to convert a byte in its ASCII representation. We may use it instead of custom approach.

Thanks, I'll take that through the nfsd tree for 3.14.

--b.

Quoted 28 lines
---
 net/sunrpc/cache.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
net/sunrpc/cache.c +1 -3
index a72de07..0877db0 100644
@@ -1111,9 +1111,7 @@ void qword_addhex(char **bpp, int *lp, char *buf, int blen)
 		*bp++ = 'x';
 		len -= 2;
 		while (blen && len >= 2) {
-			unsigned char c = *buf++;
-			*bp++ = '0' + ((c&0xf0)>>4) + (c>=0xa0)*('a'-'9'-1);
-			*bp++ = '0' + (c&0x0f) + ((c&0x0f)>=0x0a)*('a'-'9'-1);
+			bp = hex_byte_pack(bp, *buf++);
 			len -= 2;
 			blen--;
 		}
Signature · 6 lines
1.8.4.4

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html