[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1455711448-124103-9-git-send-email-andriy.shevchenko@linux.intel.com>
Date: Wed, 17 Feb 2016 14:17:26 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: "Rafael J. Wysocki" <rjw@...ysocki.net>,
"Theodore Ts'o" <tytso@....edu>, Arnd Bergmann <arnd@...db.de>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jarkko Sakkinen <jarkko.sakkinen@...ux.intel.com>,
Jani Nikula <jani.nikula@...ux.intel.com>,
David Airlie <airlied@...ux.ie>,
Benjamin Tissoires <benjamin.tissoires@...hat.com>,
Bjorn Helgaas <bhelgaas@...gle.com>,
Mathias Nyman <mathias.nyman@...el.com>,
Matt Fleming <matt@...eblueprint.co.uk>,
Lv Zheng <lv.zheng@...el.com>, Mark Brown <broonie@...nel.org>,
Zhang Rui <rui.zhang@...el.com>,
Mika Westerberg <mika.westerberg@...ux.intel.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
linux-acpi@...r.kernel.org, linux-kernel@...r.kernel.org,
dri-devel@...ts.freedesktop.org, linux-efi@...r.kernel.org,
linux-api@...r.kernel.org, linux-nvdimm@...ts.01.org
Cc: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Subject: [PATCH v1 08/10] sysctl: 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.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
---
kernel/sysctl_binary.c | 20 ++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)
diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c
index 509abe4..4e5ca94 100644
--- a/kernel/sysctl_binary.c
+++ b/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 *file,
/* 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)
@@ -1128,21 +1128,13 @@ static ssize_t bin_uuid(struct file *file,
buf[result] = '\0';
/* Convert the uuid to from a string to binary */
- for (i = 0; i < 16; i++) {
- if (!isxdigit(str[0]) || !isxdigit(str[1]))
- return -EIO;
-
- uuid[i] = (hex_to_bin(str[0]) << 4) |
- hex_to_bin(str[1]);
- str += 2;
- if (*str == '-')
- str++;
- }
+ if (uuid_be_to_bin(buf, &uuid))
+ return -EIO;
if (oldlen > 16)
oldlen = 16;
- if (copy_to_user(oldval, uuid, oldlen))
+ if (copy_to_user(oldval, &uuid, oldlen))
return -EFAULT;
copied = oldlen;
--
2.7.0
Powered by blists - more mailing lists