Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp492978imm; Thu, 31 May 2018 04:25:41 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJpPDwuPqyEJe/QTJ4YSXZRYevugcHACONUXRuURSEs5oAG9HVUAs9FPe374wuw7TXnQwDq X-Received: by 2002:a17:902:5851:: with SMTP id f17-v6mr6726082plj.32.1527765941123; Thu, 31 May 2018 04:25:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527765941; cv=none; d=google.com; s=arc-20160816; b=kxytCRrjQblkqbj4CNCH7DUK3WRn7PiW2h7qefkz06uOIYzc666H18jR/l5xSSYDyu AcpLx2+ecel6fMVRXjRb1QtgLl/s47OkmEsVcJXB2KCcJdEmwbvUzO6SXwMA6JB36ZrF 4QgP/56n842o2ZJ/o4xpwVIEvPVlxJDgAnqiMSrA3Rc0W1EqyoaWlSbvihbUJufJFpIv gvGpsxTSaA9yqmgFFKFix9eoK4EEzfa64lqe5M3b3cayqljAauBSsfJ8NQ6FgYudkrqq tEKtQXiQEHdYl8G284gOHOhVCk9+aA+cy8zhu/G4/5j5YpCl1bfFnxlY5qKuFcbiaR27 vs/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=FYgbOQQ6ai8NeInqMlsh7IRaZtJ/Lqf/jxd0HKNnLR0=; b=0rtNgkkXx9CbdIwzW1w/EXqi9IYPj2HJTReUQc3YbDSU1pY8havUkJiXAuZ8sbHl1G DMxAfsuDa6VwayCx4dC4LZk+00567hEhEsY3a/zyv+b4JVoO/7GwfDKKKid03i8Skg/i w9PDqtswVgbZrcajz8szONmf1IzwyzcK1cdNsNKLXdEF30d5+i1s7qOqT5p67Rupywi1 A/b7AXg5zo9kEhBai+9NHXIFMgyXlH9NFAURGcxEzbxe7NTg0R6UzMJI7NkUVf5sHN7t c1/yjj5TpJZWr2mVKiFa4/M5Y7E187SzdsAwXzoBaYK+1C+CJxwAHcPITwQ3JC0vR3Ex sojA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t23-v6si38720168plo.508.2018.05.31.04.25.27; Thu, 31 May 2018 04:25:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754904AbeEaLXX (ORCPT + 99 others); Thu, 31 May 2018 07:23:23 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:8170 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754822AbeEaLWt (ORCPT ); Thu, 31 May 2018 07:22:49 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 2B109F07B62E6; Thu, 31 May 2018 19:22:35 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.382.0; Thu, 31 May 2018 19:22:28 +0800 From: Yisheng Xie To: CC: , Yisheng Xie , "Kent Overstreet" , Subject: [PATCH v2 19/21] bcache: use match_string() helper Date: Thu, 31 May 2018 19:11:24 +0800 Message-ID: <1527765086-19873-20-git-send-email-xieyisheng1@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1527765086-19873-1-git-send-email-xieyisheng1@huawei.com> References: <1527765086-19873-1-git-send-email-xieyisheng1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org match_string() returns the index of an array for a matching string, which can be used instead of open coded variant. Cc: Kent Overstreet Cc: linux-bcache@vger.kernel.org Signed-off-by: Yisheng Xie --- 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