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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 0AE26C433F5 for ; Wed, 2 Mar 2022 16:55:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7AE7610EB21; Wed, 2 Mar 2022 16:55:37 +0000 (UTC) Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 03B1110E2F2 for ; Wed, 2 Mar 2022 14:04:15 +0000 (UTC) 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: Wed, 02 Mar 2022 16:55:36 +0000 X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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" Errors-To: amd-gfx-bounces@lists.freedesktop.org Sender: "amd-gfx" 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) 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 77A3BC433FE for ; Wed, 2 Mar 2022 14:04:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242579AbiCBOFH convert rfc822-to-8bit (ORCPT ); Wed, 2 Mar 2022 09:05:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242556AbiCBOFF (ORCPT ); Wed, 2 Mar 2022 09:05:05 -0500 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A7FFF89CFA for ; Wed, 2 Mar 2022 06:04:18 -0800 (PST) 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" CC: "akpm@linux-foundation.org" , "alsa-devel@alsa-project.org" , "amd-gfx@lists.freedesktop.org" , "andriy.shevchenko@linux.intel.com" , "arnd@arndb.de" , "bcm-kernel-feedback-list@broadcom.com" , "bjohannesmeyer@gmail.com" , "c.giuffrida@vu.nl" , "christian.koenig@amd.com" , "christophe.jaillet@wanadoo.fr" , "dan.carpenter@oracle.com" , "dmaengine@vger.kernel.org" , "drbd-dev@lists.linbit.com" , "dri-devel@lists.freedesktop.org" , "gustavo@embeddedor.com" , "h.j.bos@vu.nl" , "intel-gfx@lists.freedesktop.org" , "intel-wired-lan@lists.osuosl.org" , "jakobkoschel@gmail.com" , "jgg@ziepe.ca" , "keescook@chromium.org" , "kgdb-bugreport@lists.sourceforge.net" , "kvm@vger.kernel.org" , "linux-arch@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-aspeed@lists.ozlabs.org" , "linux-block@vger.kernel.org" , "linux-cifs@vger.kernel.org" , "linux-crypto@vger.kernel.org" , "linux-f2fs-devel@lists.sourceforge.net" , "linux-fsdevel@vger.kernel.org" , "linux-iio@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-media@vger.kernel.org" , "linux-mediatek@lists.infradead.org" , "linux-pm@vger.kernel.org" , "linux-rdma@vger.kernel.org" , "linux-scsi@vger.kernel.org" , "linux-sgx@vger.kernel.org" , "linux-staging@lists.linux.dev" , "linux-tegra@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-wireless@vger.kernel.org" , "linux1394-devel@lists.sourceforge.net" , "linux@rasmusvillemoes.dk" , "linuxppc-dev@lists.ozlabs.org" , "nathan@kernel.org" , "netdev@vger.kernel.org" , "nouveau@lists.freedesktop.org" , "rppt@kernel.org" , "samba-technical@lists.samba.org" , "tglx@linutronix.de" , "tipc-discussion@lists.sourceforge.net" , "v9fs-developer@lists.sourceforge.net" 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: 8BIT Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org From: Xiaomeng Tong > Sent: 02 March 2022 09:31 > > 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. > > 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. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Laight Date: Wed, 2 Mar 2022 14:04:06 +0000 Subject: [Intel-wired-lan] [PATCH 2/6] treewide: remove using list iterator after loop body as a ptr In-Reply-To: <20220302093106.8402-1-xiam0nd.tong@gmail.com> References: <20220302093106.8402-1-xiam0nd.tong@gmail.com> Message-ID: <1077f17e50d34dc2bbfdf4e52a1cb2fd@AcuMS.aculab.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: intel-wired-lan@osuosl.org List-ID: From: Xiaomeng Tong > Sent: 02 March 2022 09:31 > > 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. > > 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. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 474B4C433EF for ; Wed, 2 Mar 2022 14:04:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A4C2010E1DE; Wed, 2 Mar 2022 14:04:17 +0000 (UTC) Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 049E910E372 for ; Wed, 2 Mar 2022 14:04:15 +0000 (UTC) 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" 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 Subject: Re: [Intel-gfx] [PATCH 2/6] treewide: remove using list iterator after loop body as a ptr X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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" Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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) From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Laight Date: Wed, 2 Mar 2022 14:04:06 +0000 Subject: [PATCH 2/6] treewide: remove using list iterator after loop body as a ptr In-Reply-To: <20220302093106.8402-1-xiam0nd.tong@gmail.com> References: <20220302093106.8402-1-xiam0nd.tong@gmail.com> Message-ID: <1077f17e50d34dc2bbfdf4e52a1cb2fd@AcuMS.aculab.com> List-Id: To: linux-aspeed@lists.ozlabs.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit From: Xiaomeng Tong > Sent: 02 March 2022 09:31 > > 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. > > 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. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) 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 lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (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 1448FC433FE for ; Wed, 2 Mar 2022 14:04:22 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.94.2) (envelope-from ) id 1nPPaY-0001gh-SF; Wed, 02 Mar 2022 14:04:21 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nPPaY-0001gU-FO for linux-f2fs-devel@lists.sourceforge.net; Wed, 02 Mar 2022 14:04:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:Content-Type:MIME-Version :In-Reply-To:References:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=p84GYlKdSgY3Zq36XIO18N3khNzh9dGes2wm57cDQcs=; b=ShW7u02dG9Xpm43tDKXCouc6vo KqwmGXqox2blpGlEt3+iwq5kMbpSoJJrdBpFdxr+J4jj2uplDnKQZOdQ8YfF3y+Xa5O0BaWJWKE+J 9s4kRSwkulZwzr8Qtncw2qsK8spie4/8/m6k41o+IkVsL2kLluO0awKR04ciNqAAUNQ0=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:Content-Type:MIME-Version:In-Reply-To: References:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=p84GYlKdSgY3Zq36XIO18N3khNzh9dGes2wm57cDQcs=; b=Um5YCK/jOBfLetDu4DzWasbVwA PaSvgKL95dBygZqd1br/UC+8hrTr0FfX4OnW7o4lrjPT5avP4qXiSy752wJLBg+W7Y7O1YlWNLfYO cUeiigdmKmYdkvdJlk+lu6+RNoT1Nawhs4wbBpK977B3lHos0oWQFApGW2bayevp9ZGk=; Received: from eu-smtp-delivery-151.mimecast.com ([185.58.85.151]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.94.2) id 1nPPaU-000827-8o for linux-f2fs-devel@lists.sourceforge.net; Wed, 02 Mar 2022 14:04:20 +0000 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" 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 X-Headers-End: 1nPPaU-000827-8o Subject: Re: [f2fs-dev] [PATCH 2/6] treewide: remove using list iterator after loop body as a ptr X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net From: Xiaomeng Tong > Sent: 02 March 2022 09:31 > > 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. > > 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. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel 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 650E6C4167D for ; Wed, 2 Mar 2022 14:04:25 +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:MIME-Version:In-Reply-To:References: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sH2qf+/7x2PdEheDi5NWdKtVuYDTIlULnrq89BgQm7A=; b=n7BDFAHQgwidQO Zf7fZEhF0bgvgwAWmdMqNEUNahlQGx0lZ0gH4s+Xqg4ktd1vgd9CrVbkgRA2zjJfneLQdGxy8YYVv 2d/fzkk16AKNOnGboIKft1+ICS208MayBakJIFB872IEoZxqFF1D9My612GWaysrrNlO4OJkacxff pWrccViWeNcRbDROj1amX6cxNwIAzZExIwzQ0stUh9D1jhIxSiDpt+70Peb1V1rccb9sGQjVJk08S UjoDFmhWTk53Cx2qEXCWvtDhDDyxa8O8Uev0YZ7+nrSBkkSgDDRJ+/yY56VrMHajg1pQebJLypKU/ ejOtSBZ3qdW0udwMOExw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nPPaU-002uk9-4q; Wed, 02 Mar 2022 14:04:18 +0000 Received: from eu-smtp-delivery-151.mimecast.com ([185.58.85.151]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nPPaQ-002uhF-Hr for linux-mediatek@lists.infradead.org; Wed, 02 Mar 2022 14:04:16 +0000 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" CC: "akpm@linux-foundation.org" , "alsa-devel@alsa-project.org" , "amd-gfx@lists.freedesktop.org" , "andriy.shevchenko@linux.intel.com" , "arnd@arndb.de" , "bcm-kernel-feedback-list@broadcom.com" , "bjohannesmeyer@gmail.com" , "c.giuffrida@vu.nl" , "christian.koenig@amd.com" , "christophe.jaillet@wanadoo.fr" , "dan.carpenter@oracle.com" , "dmaengine@vger.kernel.org" , "drbd-dev@lists.linbit.com" , "dri-devel@lists.freedesktop.org" , "gustavo@embeddedor.com" , "h.j.bos@vu.nl" , "intel-gfx@lists.freedesktop.org" , "intel-wired-lan@lists.osuosl.org" , "jakobkoschel@gmail.com" , "jgg@ziepe.ca" , "keescook@chromium.org" , "kgdb-bugreport@lists.sourceforge.net" , "kvm@vger.kernel.org" , "linux-arch@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-aspeed@lists.ozlabs.org" , "linux-block@vger.kernel.org" , "linux-cifs@vger.kernel.org" , "linux-crypto@vger.kernel.org" , "linux-f2fs-devel@lists.sourceforge.net" , "linux-fsdevel@vger.kernel.org" , "linux-iio@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-media@vger.kernel.org" , "linux-mediatek@lists.infradead.org" , "linux-pm@vger.kernel.org" , "linux-rdma@vger.kernel.org" , "linux-scsi@vger.kernel.org" , "linux-sgx@vger.kernel.org" , "linux-staging@lists.linux.dev" , "linux-tegra@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-wireless@vger.kernel.org" , "linux1394-devel@lists.sourceforge.net" , "linux@rasmusvillemoes.dk" , "linuxppc-dev@lists.ozlabs.org" , "nathan@kernel.org" , "netdev@vger.kernel.org" , "nouveau@lists.freedesktop.org" , "rppt@kernel.org" , "samba-technical@lists.samba.org" , "tglx@linutronix.de" , "tipc-discussion@lists.sourceforge.net" , "v9fs-developer@lists.sourceforge.net" 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220302_060414_886803_F75B18C6 X-CRM114-Status: GOOD ( 13.59 ) 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="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Xiaomeng Tong > Sent: 02 March 2022 09:31 > > 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. > > 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. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) _______________________________________________ Linux-mediatek mailing list Linux-mediatek@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-mediatek 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 9989DC433FE for ; Tue, 8 Mar 2022 04:27:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9471410E6AF; Tue, 8 Mar 2022 04:27:34 +0000 (UTC) Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 022C710E1C3 for ; Wed, 2 Mar 2022 14:04:15 +0000 (UTC) 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" 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: Tue, 08 Mar 2022 04:27:27 +0000 Subject: Re: [Nouveau] [PATCH 2/6] treewide: remove using list iterator after loop body as a ptr X-BeenThere: nouveau@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Nouveau development list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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" Errors-To: nouveau-bounces@lists.freedesktop.org Sender: "Nouveau" 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) From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by mail19.linbit.com (LINBIT Mail Daemon) with ESMTP id 3828842179A for ; Wed, 2 Mar 2022 15:04:11 +0100 (CET) From: David Laight To: 'Xiaomeng Tong' , "torvalds@linux-foundation.org" 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> MIME-Version: 1.0 Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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" Subject: Re: [Drbd-dev] [PATCH 2/6] treewide: remove using list iterator after loop body as a ptr List-Id: "*Coordination* of development, patches, contributions -- *Questions* \(even to developers\) go to drbd-user, please." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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)