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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 B8FFAC433EF for ; Thu, 3 Mar 2022 07:05:40 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 067A81A3B; Thu, 3 Mar 2022 08:04:49 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 067A81A3B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1646291139; bh=7arDoKSYNPPf+L5dM7GJiHJ+0+C+xOQUS0nsh9OQylo=; h=From:To:Subject:Date:References:In-Reply-To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ofrrwd7i4Lq1zPzFUVyePDOPO++EKbj0EOaGHUMtj4vVm1yfEtu/Y+xjxhpwy5XQc xs5Jw/auUX3h4U3xMeEQYyEfz2OUdpIqqI/4E7QzqdcMW1xOwiGC3ifAevPYPnNv/w t4hlbJt8+P6yQRoUVLhr9Ofz5Bt6n56BmlRLhmxE= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 1DE56F8051C; Thu, 3 Mar 2022 08:03:30 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6B0B3F801D5; Wed, 2 Mar 2022 15:04:23 +0100 (CET) Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 31391F80054 for ; Wed, 2 Mar 2022 15:04:12 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 31391F80054 Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-196-4Li6Fux3PdyQ14Lo-DMf3A-1; Wed, 02 Mar 2022 14:04:10 +0000 X-MC-Unique: 4Li6Fux3PdyQ14Lo-DMf3A-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) by AcuMS.aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) with Microsoft SMTP Server (TLS) id 15.0.1497.28; Wed, 2 Mar 2022 14:04:06 +0000 Received: from AcuMS.Aculab.com ([fe80::994c:f5c2:35d6:9b65]) by AcuMS.aculab.com ([fe80::994c:f5c2:35d6:9b65%12]) with mapi id 15.00.1497.028; Wed, 2 Mar 2022 14:04:06 +0000 From: David Laight To: 'Xiaomeng Tong' , "torvalds@linux-foundation.org" Subject: RE: [PATCH 2/6] treewide: remove using list iterator after loop body as a ptr Thread-Topic: [PATCH 2/6] treewide: remove using list iterator after loop body as a ptr Thread-Index: AQHYLhg9+DU/OogLf0+tiSFmjztyUKysHu+Q Date: Wed, 2 Mar 2022 14:04:06 +0000 Message-ID: <1077f17e50d34dc2bbfdf4e52a1cb2fd@AcuMS.aculab.com> References: <20220302093106.8402-1-xiam0nd.tong@gmail.com> In-Reply-To: <20220302093106.8402-1-xiam0nd.tong@gmail.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Mailman-Approved-At: Thu, 03 Mar 2022 08:03:25 +0100 Cc: "alsa-devel@alsa-project.org" , "kvm@vger.kernel.org" , "gustavo@embeddedor.com" , "linux-iio@vger.kernel.org" , "kgdb-bugreport@lists.sourceforge.net" , "linux@rasmusvillemoes.dk" , "dri-devel@lists.freedesktop.org" , "c.giuffrida@vu.nl" , "amd-gfx@lists.freedesktop.org" , "samba-technical@lists.samba.org" , "linux1394-devel@lists.sourceforge.net" , "drbd-dev@lists.linbit.com" , "linux-arch@vger.kernel.org" , "linux-cifs@vger.kernel.org" , "linux-aspeed@lists.ozlabs.org" , "linux-scsi@vger.kernel.org" , "linux-rdma@vger.kernel.org" , "linux-staging@lists.linux.dev" , "h.j.bos@vu.nl" , "jgg@ziepe.ca" , "intel-wired-lan@lists.osuosl.org" , "nouveau@lists.freedesktop.org" , "bcm-kernel-feedback-list@broadcom.com" , "dan.carpenter@oracle.com" , "linux-media@vger.kernel.org" , "keescook@chromium.org" , "arnd@arndb.de" , "linux-pm@vger.kernel.org" , "intel-gfx@lists.freedesktop.org" , "bjohannesmeyer@gmail.com" , "linux-block@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "christophe.jaillet@wanadoo.fr" , "jakobkoschel@gmail.com" , "v9fs-developer@lists.sourceforge.net" , "linux-tegra@vger.kernel.org" , "tglx@linutronix.de" , "andriy.shevchenko@linux.intel.com" , "linux-arm-kernel@lists.infradead.org" , "linux-sgx@vger.kernel.org" , "nathan@kernel.org" , "netdev@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-wireless@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-f2fs-devel@lists.sourceforge.net" , "tipc-discussion@lists.sourceforge.net" , "linux-crypto@vger.kernel.org" , "dmaengine@vger.kernel.org" , "linux-mediatek@lists.infradead.org" , "akpm@linux-foundation.org" , "linuxppc-dev@lists.ozlabs.org" , "christian.koenig@amd.com" , "rppt@kernel.org" X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Xiaomeng Tong > Sent: 02 March 2022 09:31 >=20 > On Mon, 28 Feb 2022 16:41:04 -0800, Linus Torvalds > wrote: > > > > But basically to _me_, the important part is that the end result is > > maintainable longer-term. >=20 > I couldn't agree more. And because of that, I stick with the following > approach because it's maintainable longer-term than "type(pos) pos" one: > Implements a new macro for each list_for_each_entry* with _inside suffix= . > #define list_for_each_entry_inside(pos, type, head, member) I think that it would be better to make any alternate loop macro just set the variable to NULL on the loop exit. That is easier to code for and the compiler might be persuaded to not redo the test. It also doesn't need an extra variable defined in the for() statement so can be back-ported to older kernels without required declaration in the middle of blocks. OTOH there may be alternative definitions that can be used to get the compiler (or other compiler-like tools) to detect broken code. Even if the definition can't possibly generate a working kerrnel. =09David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1= PT, UK Registration No: 1397386 (Wales)