Skip to contentSkip to conversation

lib/vsprintf: simplify UUID printing

PATCH New [email protected] 1 participant 1 message May 21, 2016

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 88/162 lib/vsprintf: simplify UUID printing

From: Andy Shevchenko <[email protected]>
Subject: lib/vsprintf: simplify UUID printing

There are few functions here and there along with type definitions that provide UUID API. This series consolidates everything under one hood and converts current users.

This has been tested for a while internally, however it doesn't mean we covered all possible cases (especially accuracy of UUID constants after conversion). So, please test this as much as you can and provide your tag. We appreciate the effort.

The ACPI conversion is postponed for now to sort more generic things out first.

This patch (of 9):

Since we have hex_byte_pack_upper() we may use it directly and avoid second loop.

Cc Dmitry Kasatkin <[email protected]>
Cc Mimi Zohar <[email protected]>
Cc Rasmus Villemoes <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc "Theodore Ts'o" <[email protected]>
Cc Al Viro <[email protected]>
Cc Jens Axboe <[email protected]>

---

 lib/vsprintf.c |   12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
lib/vsprintf.c renamed from lib/vsprintf.c~lib-vsprintf-simplify-uuid-printing +4 -7
diff -puN lib/vsprintf.c~lib-vsprintf-simplify-uuid-printing lib/vsprintf.c
@@ -1324,7 +1324,10 @@ char *uuid_string(char *buf, char *end,
 	}
 
 	for (i = 0; i < 16; i++) {
-		p = hex_byte_pack(p, addr[index[i]]);
+		if (uc)
+			p = hex_byte_pack_upper(p, addr[index[i]]);
+		else
+			p = hex_byte_pack(p, addr[index[i]]);
 		switch (i) {
 		case 3:
 		case 5:
@@ -1337,13 +1340,6 @@ char *uuid_string(char *buf, char *end,
 
 	*p = 0;
 
-	if (uc) {
-		p = uuid;
-		do {
-			*p = toupper(*p);
-		} while (*(++p));
-	}