Skip to contentSkip to conversation

kernel/sysctl_binary.c: use generic UUID library

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

lore
Share & tools
lore
#0 lore raw

PATCH 93/162 kernel/sysctl_binary.c: use generic UUID library

From: Andy Shevchenko <[email protected]>
Subject: kernel/sysctl_binary.c: use generic UUID library

UUID library provides uuid_be type and uuid_be_to_bin() function. This substitutes open coded variant by generic library calls.

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]>

---

 kernel/sysctl_binary.c |   23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)
kernel/sysctl_binary.c renamed from kernel/sysctl_binary.c~sysctl-use-generic-uuid-library +3 -8
diff -puN kernel/sysctl_binary.c~sysctl-use-generic-uuid-library kernel/sysctl_binary.c
@@ -13,6 +13,7 @@
 #include <linux/ctype.h>
 #include <linux/netdevice.h>
 #include <linux/kernel.h>
+#include <linux/uuid.h>
 #include <linux/slab.h>
 #include <linux/compat.h>
 
@@ -1117,9 +1118,8 @@ static ssize_t bin_uuid(struct file *fil
 
 	/* Only supports reads */
 	if (oldval && oldlen) {
-		char buf[40], *str = buf;
-		unsigned char uuid[16];
-		int i;
+		char buf[UUID_STRING_LEN + 1];
+		uuid_be uuid;
 
 		result = kernel_read(file, 0, buf, sizeof(buf) - 1);
 		if (result < 0)
@@ -1127,24 +1127,15 @@ static ssize_t bin_uuid(struct file *fil
 
 		buf[result] = '\0';
 
-		/* Convert the uuid to from a string to binary */
-		for (i = 0; i < 16; i++) {
-			result = -EIO;
-			if (!isxdigit(str[0]) || !isxdigit(str[1]))
-				goto out;