From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yisheng Xie Subject: Re: [PATCH 05/33] cxgb4: use match_string() helper Date: Tue, 22 May 2018 08:55:37 +0800 Message-ID: References: <1526903890-35761-1-git-send-email-xieyisheng1@huawei.com> <1526903890-35761-6-git-send-email-xieyisheng1@huawei.com> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Cc: Linux Kernel Mailing List , Ganesh Goudar , netdev To: Andy Shevchenko Return-path: In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-Id: netdev.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 >