Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 176378
b: refs/heads/master
c: 9ac6e44
h: refs/heads/master
v: v3
  • Loading branch information
Joe Perches authored and Linus Torvalds committed Dec 15, 2009
1 parent 28648ed commit d28dc1b
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b5f54b07c06f6e438a4fee92c27423e880d8816b
refs/heads/master: 9ac6e44ee5caa5f0babfc87f2613e1296d2c2d11
62 changes: 61 additions & 1 deletion trunk/lib/vsprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,52 @@ 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 be[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
static const u8 le[16] = {3,2,1,0,5,4,7,6,8,9,10,11,12,13,14,15};
const u8 *index = be;
bool uc = false;

switch (*(++fmt)) {
case 'L':
uc = true; /* fall-through */
case 'l':
index = le;
break;
case 'B':
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;
do {
*p = toupper(*p);
} while (*(++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
Expand All @@ -858,6 +904,18 @@ 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:
* b big endian lower case hex (default)
* B big endian UPPER case hex
* l little endian lower case hex
* L little endian UPPER case hex
* big endian output byte order is:
* [0][1][2][3]-[4][5]-[6][7]-[8][9]-[10][11][12][13][14][15]
* little endian output byte order is:
* [3][2][1][0]-[5][4]-[7][6]-[8][9]-[10][11][12][13][14][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.
Expand All @@ -873,8 +931,8 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr,
case 'f':
ptr = dereference_function_descriptor(ptr);
/* Fallthrough */
case 's':
case 'S':
case 's':
return symbol_string(buf, end, ptr, spec, *fmt);
case 'R':
case 'r':
Expand All @@ -898,6 +956,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) {
Expand Down

0 comments on commit d28dc1b

Please sign in to comment.