Skip to contentSkip to conversation

lib/uuid: add a test module

PATCH New Andy Shevchenko 1 participant 2 messages May 30, 2016

Subsystems (2)
lore
Share & tools
lore

Andy Shevchenko

author reviewer
#0 lore raw

PATCH 1/2 lib/uuid: add a test module

It appears that somehow I missed a test of the latest UUID rework which landed in the kernel. Present a small test module to avoid such cases in the future.

---
 lib/Kconfig.debug |   3 ++
 lib/Makefile      |   1 +
 lib/test_uuid.c   | 133 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 137 insertions(+)
 create mode 100644 lib/test_uuid.c
lib/Kconfig.debug +3 -0
index b8ab3c3..574ae55 100644
@@ -1856,6 +1856,9 @@ config TEST_BITMAP
 
 	  If unsure, say N.
 
+config TEST_UUID
+	tristate "Test functions located in the uuid module at runtime"
+
 config TEST_RHASHTABLE
 	tristate "Perform selftest on resizable hash table"
 	default n
lib/Makefile +1 -0
index 1128e33..d374a53 100644
@@ -58,6 +58,7 @@ obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_keys.o
 obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_key_base.o
 obj-$(CONFIG_TEST_PRINTF) += test_printf.o
 obj-$(CONFIG_TEST_BITMAP) += test_bitmap.o
+obj-$(CONFIG_TEST_UUID) += test_uuid.o
 
 ifeq ($(CONFIG_DEBUG_KOBJECT),y)
 CFLAGS_kobject.o += -DDEBUG
lib/test_uuid.c new file +133 -0

133 lines not on this page · raw message

Signature · 1 line
2.8.1
author reviewer
#1 lore raw

PATCH 2/2 lib/uuid.c: use correct offset in uuid parser

From: Bjørn Mork <[email protected]>

Use '+ 0' and '+ 1' as offsets, like they were intended, instead of adding to the result.

Fixes 2b1b0d66704a ("lib/uuid.c: introduce a few more generic helpers")
---
 lib/uuid.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/uuid.c +2 -2
index e116ae5..37687af 100644
@@ -106,8 +106,8 @@ static int __uuid_to_bin(const char *uuid, __u8 b[16], const u8 ei[16])
 		return -EINVAL;
 
 	for (i = 0; i < 16; i++) {
-		int hi = hex_to_bin(uuid[si[i]] + 0);
-		int lo = hex_to_bin(uuid[si[i]] + 1);
+		int hi = hex_to_bin(uuid[si[i] + 0]);
+		int lo = hex_to_bin(uuid[si[i] + 1]);
 
 		b[ei[i]] = (hi << 4) | lo;
 	}
Signature · 1 line
2.8.1