From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A078C433F5 for ; Mon, 28 Feb 2022 05:20:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233065AbiB1FVf (ORCPT ); Mon, 28 Feb 2022 00:21:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230376AbiB1FVb (ORCPT ); Mon, 28 Feb 2022 00:21:31 -0500 Received: from relay5.hostedemail.com (relay5.hostedemail.com [64.99.140.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A58939B83 for ; Sun, 27 Feb 2022 21:20:54 -0800 (PST) Received: from omf03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id F2F3FE15; Mon, 28 Feb 2022 05:20:52 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf03.hostedemail.com (Postfix) with ESMTPA id BECCA60010; Mon, 28 Feb 2022 05:20:13 +0000 (UTC) Message-ID: Subject: Re: [PATCH v4 2/2] ALSA: core: Remove redundant variable and return the last statement From: Joe Perches To: Meng Tang , perex@perex.cz, tiwai@suse.com Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Date: Sun, 27 Feb 2022 21:20:45 -0800 In-Reply-To: <20220228050253.1649-2-tangmeng@uniontech.com> References: <20220228050253.1649-1-tangmeng@uniontech.com> <20220228050253.1649-2-tangmeng@uniontech.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.40.4-1ubuntu2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspamout08 X-Rspamd-Queue-Id: BECCA60010 X-Stat-Signature: hruc7nct77mkwtg4ah8jw8qrpgawattj X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX19B4PH4dJJF2uojux2T7euYun9bMLaYrIU= X-HE-Tag: 1646025613-188090 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2022-02-28 at 13:02 +0800, Meng Tang wrote: > Return the result from file->f_op->open() directly instead of > taking this in another redundant variable. Make the typical > return the last statement, return early and reduce the indentation > too. > > Signed-off-by: Meng Tang > Signed-off-by: Joe Perches Hi Meng Tang. For the next time: it's not necessary (or even good) to add a sign-off for another person unless they specifically authorize one. You wrote and are submitting these changes, I merely gave you simple suggestions as to how you could improve them. cheers, Joe > --- > sound/sound_core.c | 24 ++++++++++++------------ > 1 file changed, 12 insertions(+), 12 deletions(-) > > diff --git a/sound/sound_core.c b/sound/sound_core.c > index aa4a57e488e5..3332fe321737 100644 > --- a/sound/sound_core.c > +++ b/sound/sound_core.c > @@ -577,20 +577,20 @@ static int soundcore_open(struct inode *inode, struct file *file) > new_fops = fops_get(s->unit_fops); > } > spin_unlock(&sound_loader_lock); > - if (new_fops) { > - /* > - * We rely upon the fact that we can't be unloaded while the > - * subdriver is there. > - */ > - int err = 0; > - replace_fops(file, new_fops); > > - if (file->f_op->open) > - err = file->f_op->open(inode,file); > + if (!new_fops) > + return -ENODEV; > > - return err; > - } > - return -ENODEV; > + /* > + * We rely upon the fact that we can't be unloaded while the > + * subdriver is there. > + */ > + replace_fops(file, new_fops); > + > + if (!file->f_op->open) > + return -ENODEV; > + > + return file->f_op->open(inode, file); > } > > MODULE_ALIAS_CHARDEV_MAJOR(SOUND_MAJOR);