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 5FE97C41513 for ; Wed, 16 Aug 2023 14:43:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343753AbjHPOnB (ORCPT ); Wed, 16 Aug 2023 10:43:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343774AbjHPOmr (ORCPT ); Wed, 16 Aug 2023 10:42:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E41D268F; Wed, 16 Aug 2023 07:42:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2C339669E3; Wed, 16 Aug 2023 14:42:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3937C433C7; Wed, 16 Aug 2023 14:42:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1692196964; bh=Onf8GBQ42sfUuG/X+JQV54DEIRlWJ+k2bjhvUDfua9M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NhbKHsh29N+CyM6scVJy+tK2FuiWOpM6D/FhGzi9Jl4I/e/Pz8WqmnRj6uPprhyGi 68prQxeoAvMRfIex1nJuOcLD/5fkIQk1Hz57+Zfl0whWIGk9VYLVSk1kvOL/F3xUuI 2lfkKC2/50dyHyf5pbdScxcWE9u4EbN17HSkCMuc= Date: Wed, 16 Aug 2023 16:42:41 +0200 From: Greg KH To: Atul Kumar Pant Cc: richard.leitner@linux.dev, wsa+renesas@sang-engineering.com, mhocko@suse.com, surenb@google.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, shuah@kernel.org Subject: Re: [PATCH v1] drivers: usb: Removes use of assignment in if condition Message-ID: <2023081606-geology-purging-8ff1@gregkh> References: <20230815204141.51972-1-atulpant.linux@gmail.com> <2023081550-absurd-sprint-65e5@gregkh> <20230816034313.GA57824@atom0118> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230816034313.GA57824@atom0118> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org On Wed, Aug 16, 2023 at 09:13:13AM +0530, Atul Kumar Pant wrote: > On Tue, Aug 15, 2023 at 11:07:02PM +0200, Greg KH wrote: > > On Wed, Aug 16, 2023 at 02:11:41AM +0530, Atul Kumar Pant wrote: > > > This patch fixes following checkpatch.pl issue: > > > ERROR: do not use assignment in if condition > > > > > > Signed-off-by: Atul Kumar Pant > > > --- > > > drivers/usb/core/devio.c | 3 ++- > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c > > > index e501a03d6c70..56899fed6bd4 100644 > > > --- a/drivers/usb/core/devio.c > > > +++ b/drivers/usb/core/devio.c > > > @@ -2333,9 +2333,10 @@ static int proc_ioctl(struct usb_dev_state *ps, struct usbdevfs_ioctl *ctl) > > > } > > > } > > > > > > + intf = usb_ifnum_to_if(ps->dev, ctl->ifno); > > > if (ps->dev->state != USB_STATE_CONFIGURED) > > > retval = -EHOSTUNREACH; > > > - else if (!(intf = usb_ifnum_to_if(ps->dev, ctl->ifno))) > > > + else if (!intf) > > > > Did you mean to change the logic here by doing the calculation always? > > Does that change functionality? > > > Now the calculation of interface will be done always, which can be > redundant. But this would not change the functionality. Yes, but it is now redundant, so this change isn't really needed, the original code is "more correct", please leave it as-is. thanks, greg k-h