Message ID | 1507728e0ea3deafa71c481d508a6e9765c92221.1254030722.git.joe@perches.com |
---|---|
State | Not Applicable, archived |
Delegated to: | David Miller |
Headers | show |
Hi Joe, On Sunday 27 September 2009, Joe Perches wrote: > UUID/GUIDs are somewhat common in kernel source. > > Standardize the printed style of UUID/GUIDs by using > another extension to %p. > > %pU: 01020304:0506:0708:090a:0b0c0d0e0f10 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ here > %pUr: 04030201:0605:0807:0a09:0b0c0d0e0f10 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ and here Code does "01020304-0506-0708-090a-0b0c0d0e0f10". This is not, what commit promises. Please change the commit message! Best Regards Ingo Oeser -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Sun, 2009-09-27 at 12:45 +0200, Ingo Oeser wrote: > Hi Joe, Hello Ingo. > On Sunday 27 September 2009, Joe Perches wrote: > > UUID/GUIDs are somewhat common in kernel source. > > Standardize the printed style of UUID/GUIDs by using > > another extension to %p. > > %pU: 01020304:0506:0708:090a:0b0c0d0e0f10 > > %pUr: 04030201:0605:0807:0a09:0b0c0d0e0f10 > Code does "01020304-0506-0708-090a-0b0c0d0e0f10". > This is not, what commit promises. Please change the commit message! True enough, that can change, no worries. Does anyone have comments like: 1 what a stupid idea 2 how unnecessary 3 meh 4 bloat alert! linux is supposed to be lean 5 ok idea, bad implementation 6 sure, why not -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Sun, Sep 27, 2009 at 12:00:46PM -0700, Joe Perches wrote: > On Sun, 2009-09-27 at 12:45 +0200, Ingo Oeser wrote: > > Hi Joe, > > Hello Ingo. > > > On Sunday 27 September 2009, Joe Perches wrote: > > > UUID/GUIDs are somewhat common in kernel source. > > > Standardize the printed style of UUID/GUIDs by using > > > another extension to %p. > > > %pU: 01020304:0506:0708:090a:0b0c0d0e0f10 > > > %pUr: 04030201:0605:0807:0a09:0b0c0d0e0f10 > > Code does "01020304-0506-0708-090a-0b0c0d0e0f10". > > This is not, what commit promises. Please change the commit message! > > True enough, that can change, no worries. > > Does anyone have comments like: > > 1 what a stupid idea > 2 how unnecessary > 3 meh > 4 bloat alert! linux is supposed to be lean > 5 ok idea, bad implementation > 6 sure, why not Sure, why not :) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index b91839e..68a49bb 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -790,6 +790,53 @@ static char *ip4_addr_string(char *buf, char *end, const u8 *addr, return string(buf, end, ip4_addr, spec); } +static char *uuid_string(char *buf, char *end, const u8 *addr, + struct printf_spec spec, const char *fmt) +{ + char uuid[sizeof("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")]; + char *p = uuid; + int i; + static const u8 r[16] = {3,2,1,0,5,4,7,6,8,9,10,11,12,13,14,15}; + static const u8 n[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + const u8 *index = n; + bool uc = false; + + while (isalnum(*(++fmt))) { + switch (*fmt) { + case 'r': + index = r; + break; + case 'X': + uc = true; + break; + } + } + + for (i = 0; i < 16; i++) { + p = pack_hex_byte(p, addr[index[i]]); + switch (i) { + case 3: + case 5: + case 7: + case 9: + *p++ = '-'; + break; + } + } + + *p = 0; + + if (uc) { + p = uuid; + while (*p) { + *p = toupper(*p); + p++; + } + } + + return string(buf, end, uuid, spec); +} + /* * Show a '%p' thing. A kernel extension is that the '%p' is followed * by an extra set of alphanumeric characters that are extended format @@ -814,6 +861,13 @@ static char *ip4_addr_string(char *buf, char *end, const u8 *addr, * IPv4 uses dot-separated decimal with leading 0's (010.123.045.006) * - 'I6c' for IPv6 addresses printed as specified by * http://www.ietf.org/id/draft-kawamura-ipv6-text-representation-03.txt + * - 'U' For a 16 byte UUID/GUID, it prints the UUID/GUID in the form + * "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + * Options for %pU are: + * 'X' use upper case hex digits + * 'r' use LE byte order for U32 and U16s equivalents. Use indices: + * [3][2][1][0]-[5][4]-[7][6]-[9][8]-[10]...[15] + * * Note: The difference between 'S' and 'F' is that on ia64 and ppc64 * function pointers are really function descriptors, which contain a * pointer to the real address. @@ -828,9 +882,9 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr, case 'F': case 'f': ptr = dereference_function_descriptor(ptr); - case 's': /* Fallthrough */ case 'S': + case 's': return symbol_string(buf, end, ptr, spec, *fmt); case 'R': return resource_string(buf, end, ptr, spec); @@ -853,6 +907,8 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr, return ip4_addr_string(buf, end, ptr, spec, fmt); } break; + case 'U': + return uuid_string(buf, end, ptr, spec, fmt); } spec.flags |= SMALL; if (spec.field_width == -1) {
UUID/GUIDs are somewhat common in kernel source. Standardize the printed style of UUID/GUIDs by using another extension to %p. %pU: 01020304:0506:0708:090a:0b0c0d0e0f10 %pUr: 04030201:0605:0807:0a09:0b0c0d0e0f10 %pU[r]X:Use upper case hex Signed-off-by: Joe Perches <joe@perches.com> --- lib/vsprintf.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 57 insertions(+), 1 deletions(-)