From: Takashi Iwai Subject: Re: [PATCH v2 15/21] ALSA: oxygen: use match_string() helper Date: Thu, 31 May 2018 20:59:33 +0200 Message-ID: References: <1527765086-19873-1-git-send-email-xieyisheng1@huawei.com> <1527765086-19873-16-git-send-email-xieyisheng1@huawei.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Return-path: In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: Andy Shevchenko Cc: Yisheng Xie , ALSA Development Mailing List , Clemens Ladisch , Jaroslav Kysela , Linux Kernel Mailing List List-Id: alsa-devel@alsa-project.org On Thu, 31 May 2018 20:41:36 +0200, Andy Shevchenko wrote: > > On Thu, May 31, 2018 at 2:11 PM, Yisheng Xie wrote: > > match_string() returns the index of an array for a matching string, > > which can be used instead of open coded variant. > > Sorry, didn't notice before one thing: > > > + j = match_string(known_ctl_names, CONTROL_COUNT, ctl->id.name); > > + if (j >= 0) { > > + chip->controls[j] = ctl; > > + ctl->private_free = oxygen_any_ctl_free; > > + } > > It looks to me you may get rid of j completely by utilizing existing err. Well, err isn't ideal as it's referred as the actual index. That is, the line below looks weird to me: chip->controls[err] = ctl; Of course, j isn't the best name, either, but at least, keeping the same variable makes the code conversion logic clearer. thanks, Takashi