diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2016-05-20 20:01:04 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-05-20 20:58:30 -0400 |
commit | 2b1b0d66704a8cafe83be7114ec4c15ab3a314ad (patch) | |
tree | 4ad1f40e5907b94bac6a7499e11962bbf6a843c0 /lib/vsprintf.c | |
parent | 8da4b8c48e7b43cb16d05e1dbb34ad9f73ab7efd (diff) |
lib/uuid.c: introduce a few more generic helpers
There are new helpers in this patch:
uuid_is_valid checks if a UUID is valid
uuid_be_to_bin converts from string to binary (big endian)
uuid_le_to_bin converts from string to binary (little endian)
They will be used in future, i.e. in the following patches in the series.
This also moves the indices arrays to lib/uuid.c to be shared accross
modules.
[andriy.shevchenko@linux.intel.com: fix typo]
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Dmitry Kasatkin <dmitry.kasatkin@gmail.com>
Cc: Mimi Zohar <zohar@linux.vnet.ibm.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/vsprintf.c')
-rw-r--r-- | lib/vsprintf.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index be0e7cf11e48..0967771d8f7f 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/ioport.h> | 30 | #include <linux/ioport.h> |
31 | #include <linux/dcache.h> | 31 | #include <linux/dcache.h> |
32 | #include <linux/cred.h> | 32 | #include <linux/cred.h> |
33 | #include <linux/uuid.h> | ||
33 | #include <net/addrconf.h> | 34 | #include <net/addrconf.h> |
34 | #ifdef CONFIG_BLOCK | 35 | #ifdef CONFIG_BLOCK |
35 | #include <linux/blkdev.h> | 36 | #include <linux/blkdev.h> |
@@ -1304,19 +1305,17 @@ static noinline_for_stack | |||
1304 | char *uuid_string(char *buf, char *end, const u8 *addr, | 1305 | char *uuid_string(char *buf, char *end, const u8 *addr, |
1305 | struct printf_spec spec, const char *fmt) | 1306 | struct printf_spec spec, const char *fmt) |
1306 | { | 1307 | { |
1307 | char uuid[sizeof("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")]; | 1308 | char uuid[UUID_STRING_LEN + 1]; |
1308 | char *p = uuid; | 1309 | char *p = uuid; |
1309 | int i; | 1310 | int i; |
1310 | static const u8 be[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; | 1311 | const u8 *index = uuid_be_index; |
1311 | static const u8 le[16] = {3,2,1,0,5,4,7,6,8,9,10,11,12,13,14,15}; | ||
1312 | const u8 *index = be; | ||
1313 | bool uc = false; | 1312 | bool uc = false; |
1314 | 1313 | ||
1315 | switch (*(++fmt)) { | 1314 | switch (*(++fmt)) { |
1316 | case 'L': | 1315 | case 'L': |
1317 | uc = true; /* fall-through */ | 1316 | uc = true; /* fall-through */ |
1318 | case 'l': | 1317 | case 'l': |
1319 | index = le; | 1318 | index = uuid_le_index; |
1320 | break; | 1319 | break; |
1321 | case 'B': | 1320 | case 'B': |
1322 | uc = true; | 1321 | uc = true; |