lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1527765086-19873-20-git-send-email-xieyisheng1@huawei.com>
Date:   Thu, 31 May 2018 19:11:24 +0800
From:   Yisheng Xie <xieyisheng1@...wei.com>
To:     <linux-kernel@...r.kernel.org>
CC:     <andy.shevchenko@...il.com>, Yisheng Xie <xieyisheng1@...wei.com>,
        "Kent Overstreet" <kent.overstreet@...il.com>,
        <linux-bcache@...r.kernel.org>
Subject: [PATCH v2 19/21] bcache: use match_string() helper

match_string() returns the index of an array for a matching string,
which can be used instead of open coded variant.

Cc: Kent Overstreet <kent.overstreet@...il.com>
Cc: linux-bcache@...r.kernel.org 
Signed-off-by: Yisheng Xie <xieyisheng1@...wei.com>
---
 drivers/md/bcache/util.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/md/bcache/util.c b/drivers/md/bcache/util.c
index 74febd5..cd1f4fd 100644
--- a/drivers/md/bcache/util.c
+++ b/drivers/md/bcache/util.c
@@ -136,22 +136,17 @@ ssize_t bch_snprint_string_list(char *buf, size_t size, const char * const list[
 
 ssize_t bch_read_string_list(const char *buf, const char * const list[])
 {
-	size_t i;
+	ssize_t i;
 	char *s, *d = kstrndup(buf, PAGE_SIZE - 1, GFP_KERNEL);
 	if (!d)
 		return -ENOMEM;
 
 	s = strim(d);
 
-	for (i = 0; list[i]; i++)
-		if (!strcmp(list[i], s))
-			break;
+	i = match_string(list, -1, s);
 
 	kfree(d);
 
-	if (!list[i])
-		return -EINVAL;
-
 	return i;
 }
 
-- 
1.7.12.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ