Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp950204imm; Mon, 21 May 2018 17:56:13 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrYAWkdawl0BW6iFgnGxe0LKAho+5seIZmVmQ3vM04RsG3raC9xzAhCjuXSyPktxhOslDUN X-Received: by 2002:a62:c413:: with SMTP id y19-v6mr22022087pff.97.1526950573367; Mon, 21 May 2018 17:56:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526950573; cv=none; d=google.com; s=arc-20160816; b=rnuOmYs1j9uGQ8v0sz5HBfSb54gkJZQktsyFNdbUMKdJEmR2apB82OmxTDhRjUrpeI J7lO7O2NTnRbpZPtg7h85YCioLo4NYmvd65UJfmcieXasK+LxkbN9E7nYKBdPGVSs23B VcVEQeJ/JfczsArOnN1ZA/NZHeoVPaMWVblBZxYtbKohlQhbDkgPNLPkuwokML7yr4tw FB1a20zsLgYJ5on6QZ868JRc+eoQogZTO3fmwxJBAkx0WIeJ9Tm8ioL6RkYxlscSjpeW E6gYZayjimYRDxtNTWIhLirU9KmMZ+pK0qguIHaXSq+06GBU+/tjgw0Co4j2ErtDUS83 5z6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:arc-authentication-results; bh=mDkNYZ7a8mKT4d6C51ffKKRvCmyNTrk5AbgXzIExv1o=; b=EglqJf9vB5SGCIyED3zKvd+MSkobeQSHMQwQd3QGSXnDbrCyhIdZaIPZGhgUm1LTBE x52sVCMo3ajZeh2+IguvifPCG9D/VYj+IsSNaUjF6WJPtdGdKMtRd5wyoxqbbsm3idE5 M0UFAGqFN4ytm4ycsOpVp17IuHhSWro8f9HSM1tsH/i+wweIi0a5YDlrwOdDltfdeyKA 6xQy6QMf6WDkxtGR6K1NCN0vCASJQ+HJINFdzFkyPQzRyvf/SIyy2tQ11rqCv8D61NGO 9dLU2JtZqxavNwvy15Drw5iitfmPdhNS5aBFym5XW9FYC5qEXnaFh5DW4er/C26uAJfC HlBw== 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 y11-v6si15829878plt.455.2018.05.21.17.55.57; Mon, 21 May 2018 17:56:13 -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 S1751870AbeEVAzq (ORCPT + 99 others); Mon, 21 May 2018 20:55:46 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:60819 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751535AbeEVAzn (ORCPT ); Mon, 21 May 2018 20:55:43 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 71BF61DC9B067; Tue, 22 May 2018 08:55:39 +0800 (CST) Received: from [127.0.0.1] (10.177.29.40) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.382.0; Tue, 22 May 2018 08:55:39 +0800 Subject: Re: [PATCH 05/33] cxgb4: use match_string() helper To: Andy Shevchenko References: <1526903890-35761-1-git-send-email-xieyisheng1@huawei.com> <1526903890-35761-6-git-send-email-xieyisheng1@huawei.com> CC: Linux Kernel Mailing List , Ganesh Goudar , netdev From: Yisheng Xie Message-ID: Date: Tue, 22 May 2018 08:55:37 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.29.40] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andy, On 2018/5/22 5:39, Andy Shevchenko wrote: > On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie wrote: >> match_string() returns the index of an array for a matching string, >> which can be used intead of open coded variant. > >> - for (i = 0; i < ARRAY_SIZE(cudbg_region); i++) { >> - if (!strcmp(cudbg_region[i], region_name)) { >> - found = 1; >> - idx = i; >> - break; >> - } >> - } >> - if (!found) >> - return -EINVAL; >> + rc = match_string(cudbg_region, ARRAY_SIZE(cudbg_region), region_name); >> + if (rc < 0) >> + return rc; >> >> - found = 0; >> + idx = rc; > > Is found still in use after this? > If so, is it initialized properly now? it is initialized when define 'found', so no need to be initialized once more. Thanks Yisheng >