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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 79A6AC433EF for ; Tue, 1 Mar 2022 00:41:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Mime-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ZIZsNwhfeb+zNZfSWLe0PadQQ77C3zNYN7qNDxIQzss=; b=34tRqLPc9zJbch 4Yv9GIJt2lszhXG8bpktkkE0SXm3RO/MBUYAWXmPvQri4golO6OK8EVdjtShlVL3YxxndupUGmkm+ dG+d4nuOWgza0oLMSNIzdSV76GO3uZCmsxXXK8QrTow9+WDVCfsJbRC7Up9E1/UdFV9/Y0yNrqwFi uJ8V7nHN4aGfgfRZYIk6ykPj9W+HGnn+0oZztqaRNLWc2N7qYhsdylSaPlMNnT86uOldI7aXOrxJT E4jzKZ53eilpbkxyTJ/hb1efB/rLrER61cicmB/hXudjuhHyKeXoknMBrNj8E9bHLad09mA2rUzRO 6nEFWkds98l2AE8lwZIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOqZV-00EW0e-4G; Tue, 01 Mar 2022 00:40:57 +0000 Received: from gate.crashing.org ([63.228.1.57]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOqZR-00EVzN-5P; Tue, 01 Mar 2022 00:40:54 +0000 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 2210V56x017328; Mon, 28 Feb 2022 18:31:05 -0600 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 2210V0er017322; Mon, 28 Feb 2022 18:31:00 -0600 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Mon, 28 Feb 2022 18:30:59 -0600 From: Segher Boessenkool To: James Bottomley Cc: Mike Rapoport , Christian =?iso-8859-1?Q?K=F6nig?= , Linus Torvalds , linux-wireless , alsa-devel@alsa-project.org, KVM list , "Gustavo A. R. Silva" , linux-iio@vger.kernel.org, nouveau@lists.freedesktop.org, Rasmus Villemoes , dri-devel , Cristiano Giuffrida , "Bos, H.J." , linux1394-devel@lists.sourceforge.net, drbd-dev@lists.linbit.com, linux-arch , CIFS , linux-aspeed@lists.ozlabs.org, linux-scsi , linux-rdma , linux-staging@lists.linux.dev, amd-gfx list , Jason Gunthorpe , intel-wired-lan@lists.osuosl.org, kgdb-bugreport@lists.sourceforge.net, bcm-kernel-feedback-list@broadcom.com, Dan Carpenter , Linux Media Mailing List , Kees Cook , Arnd Bergman , Linux PM , intel-gfx , Brian Johannesmeyer , Nathan Chancellor , dma , Christophe JAILLET , Jakob Koschel , v9fs-developer@lists.sourceforge.net, linux-tegra , Thomas Gleixner , Andy Shevchenko , Linux ARM , linux-sgx@vger.kernel.org, linux-block , Netdev , linux-usb@vger.kernel.org, samba-technical@lists.samba.org, Linux Kernel Mailing List , Linux F2FS Dev Mailing List , tipc-discussion@lists.sourceforge.net, Linux Crypto Mailing List , linux-fsdevel , linux-mediatek@lists.infradead.org, Andrew Morton , linuxppc-dev Subject: Re: [PATCH 2/6] treewide: remove using list iterator after loop body as a ptr Message-ID: <20220301003059.GE614@gate.crashing.org> References: <20220228110822.491923-1-jakobkoschel@gmail.com> <20220228110822.491923-3-jakobkoschel@gmail.com> <2e4e95d6-f6c9-a188-e1cd-b1eae465562a@amd.com> <282f0f8d-f491-26fc-6ae0-604b367a5a1a@amd.com> <7D0C2A5D-500E-4F38-AD0C-A76E132A390E@kernel.org> <73fa82a20910c06784be2352a655acc59e9942ea.camel@HansenPartnership.com> Mime-Version: 1.0 Content-Disposition: inline In-Reply-To: <73fa82a20910c06784be2352a655acc59e9942ea.camel@HansenPartnership.com> User-Agent: Mutt/1.4.2.3i X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220228_164053_457718_28822910 X-CRM114-Status: GOOD ( 28.18 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org On Mon, Feb 28, 2022 at 05:28:58PM -0500, James Bottomley wrote: > On Mon, 2022-02-28 at 23:59 +0200, Mike Rapoport wrote: > > = > > On February 28, 2022 10:42:53 PM GMT+02:00, James Bottomley < > > James.Bottomley@HansenPartnership.com> wrote: > > > On Mon, 2022-02-28 at 21:07 +0100, Christian K=F6nig wrote: > [...] > > > > > I do wish we could actually poison the 'pos' value after the > > > > > loop somehow - but clearly the "might be uninitialized" I was > > > > > hoping for isn't the way to do it. > > > > > = > > > > > Anybody have any ideas? > > > > = > > > > I think we should look at the use cases why code is touching > > > > (pos) after the loop. > > > > = > > > > Just from skimming over the patches to change this and experience > > > > with the drivers/subsystems I help to maintain I think the > > > > primary pattern looks something like this: > > > > = > > > > list_for_each_entry(entry, head, member) { > > > > if (some_condition_checking(entry)) > > > > break; > > > > } > > > > do_something_with(entry); > > > = > > > Actually, we usually have a check to see if the loop found > > > anything, but in that case it should something like > > > = > > > if (list_entry_is_head(entry, head, member)) { > > > return with error; > > > } > > > do_somethin_with(entry); > > > = > > > Suffice? The list_entry_is_head() macro is designed to cope with > > > the bogus entry on head problem. > > = > > Won't suffice because the end goal of this work is to limit scope of > > entry only to loop. Hence the need for additional variable. > = > Well, yes, but my objection is more to the size of churn than the > desire to do loop local. I'm not even sure loop local is possible, > because it's always annoyed me that for (int i =3D 0; ... in C++ defines > i in the outer scope not the loop scope, which is why I never use it. In C its scope is the rest of the declaration and the entire loop, not anything after it. This was the same in C++98 already, btw (but in pre-standard versions of C++ things were like you remember, yes, and it was painful). Segher _______________________________________________ Linux-mediatek mailing list Linux-mediatek@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-mediatek