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.86.151]) by mail19.linbit.com (LINBIT Mail Daemon) with ESMTP id 3374242036B for ; Mon, 7 Mar 2022 16:26:53 +0100 (CET) From: David Laight To: 'Dan Carpenter' , Jakob Koschel Date: Mon, 7 Mar 2022 15:26:48 +0000 Message-ID: References: <20220228110822.491923-1-jakobkoschel@gmail.com> <20220307150037.GD3293@kadam> In-Reply-To: <20220307150037.GD3293@kadam> MIME-Version: 1.0 Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: "linux-wireless@vger.kernel.org" , "alsa-devel@alsa-project.org" , "kvm@vger.kernel.org" , "Gustavo A. R. Silva" , "linux-iio@vger.kernel.org" , "nouveau@lists.freedesktop.org" , Rasmus Villemoes , "dri-devel@lists.freedesktop.org" , Cristiano Giuffrida , "amd-gfx@lists.freedesktop.org" , "linux1394-devel@lists.sourceforge.net" , "drbd-dev@lists.linbit.com" , linux-arch , "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" , "Bos, H.J." , Jason Gunthorpe , "intel-wired-lan@lists.osuosl.org" , "kgdb-bugreport@lists.sourceforge.net" , "bcm-kernel-feedback-list@broadcom.com" , "linux-media@vger.kernel.org" , Kees Cook , Arnd Bergman , "linux-pm@vger.kernel.org" , "intel-gfx@lists.freedesktop.org" , "linuxppc-dev@lists.ozlabs.org" , Brian Johannesmeyer , "linux-block@vger.kernel.org" , "dmaengine@vger.kernel.org" , Christophe JAILLET , "v9fs-developer@lists.sourceforge.net" , "linux-tegra@vger.kernel.org" , Thomas Gleixner , Andy Shevchenko , "linux-arm-kernel@lists.infradead.org" , "linux-sgx@vger.kernel.org" , Nathan Chancellor , "netdev@vger.kernel.org" , "linux-usb@vger.kernel.org" , "samba-technical@lists.samba.org" , "linux-kernel@vger.kernel.org" , "linux-f2fs-devel@lists.sourceforge.net" , "tipc-discussion@lists.sourceforge.net" , "linux-crypto@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-mediatek@lists.infradead.org" , Andrew Morton , Linus Torvalds , Mike Rapoport Subject: Re: [Drbd-dev] [PATCH 0/6] Remove usage of list iterator past the loop body 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: Dan Carpenter > Sent: 07 March 2022 15:01 >=20 > Updating this API is risky because some places rely on the old behavior > and not all of them have been updated. Here are some additional places > you might want to change. I really can't help thinking that trying to merge this patch is actually impossible. It affects far too many different parts of the tree. Since (I believe) this is a doubly linked list with forwards and backwards pointers that point to a 'node' (not that there is a nice comment to that effect in the header - and there are lots of ways to do linked lists) the 'head' pretty much has to be a 'node'. I'd write the following new defines (but I might be using the old names here): list_first(head, field) First item, NULL if empty. list_last(head, field) Last item NULL if empty. list_next(head, item, field) Item after 'item', NULL if last. list_prev(head, item. field) Item before 'item', NULL if first. You get (something like): #define list_first(head, field) \ =09head->next =3D=3D &head ? NULL : list_item(head->next, field) (probably needs typeof(item) from somewhere). The iterator loop is then just: #define loop_iterate(item, head, field) \ =09for (item =3D list_first(head, field); item; \ =09=09item =3D list_next(head, item, field) I'm not sure, but making the 'head' be a structure that contains a single member that is a 'node' might help type checking. Then all the code that uses the current defines can slowly be moved over (probably a couple of releases) before the existing defines are deleted. That should simplify all the open-coded search loops that are just as likely to be buggy (possibly more so). =09David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1= PT, UK Registration No: 1397386 (Wales)