Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1320948pxp; Sun, 6 Mar 2022 11:40:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJw+jJLlPf+AjpgzIBYQ0ZYhnZkC91ZkzHkJ+gJblE+/PhKyQ5JsgC1fOKEBd1KLYf+Z0Ymw X-Received: by 2002:a63:4665:0:b0:374:7305:dab4 with SMTP id v37-20020a634665000000b003747305dab4mr7169751pgk.256.1646595626710; Sun, 06 Mar 2022 11:40:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646595626; cv=none; d=google.com; s=arc-20160816; b=VtxOR+4okhYKD/k2/7y+mOqqkffAU8//Qo9tmzOhSULg38rSKIMT6G7c9BFSTiY4bk tdZxqySsvVu9CtqOM+Ro0LriPCefUmMC2aye0jjhA/cEwC2DA2L9kZ6AdEGJRdvf6vXQ QQUUZXuwSmbGQP8HuvNAKOX/gi/IXflI1ZcDIZHUqDGCYqP4SvCaDBGIOX5J5ESNhUgG NU24qiO2He7D9JJPxt+iprTNw91AZ+s6wHHtPBzs95sxtadqayBkonmFJlHcnRG4euz9 hV/iysSyRxfkSo9RN2SnujXBcAZ0epf8gCpRvuPC6hyfJaZYGHl6Rtk2PEaofCWzxxgY 8lzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=6CENKQ9JhRmEaOgZfoAMTXk6vCxN4E6JObiI8H9nvkA=; b=ykMv4qd4LmIQ8B8JZ/yqz7EWg674E2pjmINo81Pz3D6MYo+xfZPkVcZrWj+1mra52b vJWciyt5Z8+rosJkNP5ToLlQZeP0hKom5MvnuSVao7p+IaVfrc0TRMMEQQphabuV3wwD Xj460d8KhsUQllVc2U6CCkYuma5DLkHPlg3tsI3+lD6QjGfFvhWgO/HOcdGArcLelsDj +4AuritiupBicMXyTL7GwyCdGM7s0dQaxbeR1DtilMDr6/oQf3HrBMhbX3VHDjCuDkoZ MLXGq6IdMuAjMEdt6j31RzNy6M51WWljzVCfnCujF1aduY1XZg1APsH7rGmhp4AqcrsB Rdeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rPFmLs3H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p11-20020a170902b08b00b0014fa0b5cac8si10191227plr.304.2022.03.06.11.40.10; Sun, 06 Mar 2022 11:40:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rPFmLs3H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231908AbiCFSBC (ORCPT + 99 others); Sun, 6 Mar 2022 13:01:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231256AbiCFSBA (ORCPT ); Sun, 6 Mar 2022 13:01:00 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 126763EF37; Sun, 6 Mar 2022 10:00:08 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B2AA9B80EBE; Sun, 6 Mar 2022 18:00:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6463AC340EC; Sun, 6 Mar 2022 18:00:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646589605; bh=HZP74ZA4RW2ibfRByAf5KWvT/L7pk7G/fjmfHeBhJD0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=rPFmLs3H6+2+NS3g3jxd6sVwEX3G8BorFRhHe5/+q54jru0FUXLK9xUYb+4B6eB+2 iWPwoBI4Fh3j6h9WJQNO+ojbIM2SoUsM+v6y0hEQHFyVVio3gKIDsqnVFbJfoaWaXQ 4hD4RDZMKn7uDHG3kb9yPMFQGisOh3cdrINAtU7w= Date: Sun, 6 Mar 2022 19:00:01 +0100 From: Greg KH To: Jakob Koschel Cc: linux-kernel@vger.kernel.org, Linus Torvalds , Felipe Balbi , Joel Stanley , Andrew Jeffery , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Cristian Birsan , Al Cooper , Li Yang , Vladimir Zapolskiy , Daniel Mack , Haojian Zhuang , Robert Jarzmik , Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , Jonathan Hunter , Michal Simek , "open list:USB GADGET/PERIPHERAL SUBSYSTEM" , Mike Rapoport , Brian Johannesmeyer , Cristiano Giuffrida , "Bos, H.J." Subject: Re: [PATCH 25/26] usb: gadget: dummy_hcd: replace usage of rc to check if a list element was found Message-ID: References: <20220306175034.3084609-1-jakobkoschel@gmail.com> <20220306175034.3084609-26-jakobkoschel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220306175034.3084609-26-jakobkoschel@gmail.com> X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Mar 06, 2022 at 06:50:33PM +0100, Jakob Koschel wrote: > To move the list iterator variable into the list_for_each_entry_*() > macro in the future it should be avoided to use the list iterator > variable after the loop body. > > To *never* use the list iterator variable after the loop it was > concluded to use a separate iterator variable [1]. > > This removes the need to check the rc value to determine if the > break/goto was hit and can be made more obvious > by checking if the variable was set within the list traversal loop. > > Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/ > Signed-off-by: Jakob Koschel > --- > drivers/usb/gadget/udc/dummy_hcd.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > > diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c > index a2d956af42a2..f21944707707 100644 > --- a/drivers/usb/gadget/udc/dummy_hcd.c > +++ b/drivers/usb/gadget/udc/dummy_hcd.c > @@ -751,7 +751,7 @@ static int dummy_dequeue(struct usb_ep *_ep, struct usb_request *_req) > struct dummy *dum; > int retval = -EINVAL; > unsigned long flags; > - struct dummy_request *req = NULL; > + struct dummy_request *req = NULL, *tmp; > > if (!_ep || !_req) > return retval; > @@ -763,17 +763,18 @@ static int dummy_dequeue(struct usb_ep *_ep, struct usb_request *_req) > > local_irq_save(flags); > spin_lock(&dum->lock); > - list_for_each_entry(req, &ep->queue, queue) { > - if (&req->req == _req) { > - list_del_init(&req->queue); > + list_for_each_entry(tmp, &ep->queue, queue) { > + if (&tmp->req == _req) { > + list_del_init(&tmp->queue); > _req->status = -ECONNRESET; > + req = tmp; > retval = 0; > break; > } > } > spin_unlock(&dum->lock); > > - if (retval == 0) { > + if (req) { There's no need for this change as we are testing retval, not req here, unlike the other udc drivers. So this one I think is correct as-is, or am I mistaken somehow? thanks, greg k-h