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 C05C7C43217 for ; Mon, 7 Mar 2022 15:27:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243803AbiCGP2H convert rfc822-to-8bit (ORCPT ); Mon, 7 Mar 2022 10:28:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243754AbiCGP1z (ORCPT ); Mon, 7 Mar 2022 10:27:55 -0500 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8222C92D03 for ; Mon, 7 Mar 2022 07:27:00 -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-85-dcBRBPURPaqNT771jbYVzw-1; Mon, 07 Mar 2022 15:26:52 +0000 X-MC-Unique: dcBRBPURPaqNT771jbYVzw-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; Mon, 7 Mar 2022 15:26:48 +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; Mon, 7 Mar 2022 15:26:48 +0000 From: David Laight To: 'Dan Carpenter' , Jakob Koschel CC: "alsa-devel@alsa-project.org" , "linux-aspeed@lists.ozlabs.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" , "samba-technical@lists.samba.org" , "linux1394-devel@lists.sourceforge.net" , "drbd-dev@lists.linbit.com" , linux-arch , "linux-cifs@vger.kernel.org" , "kvm@vger.kernel.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" , Brian Johannesmeyer , "linux-block@vger.kernel.org" , "linux-fsdevel@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 , "Linus Torvalds" , "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" , "netdev@vger.kernel.org" , "dmaengine@vger.kernel.org" , "linux-mediatek@lists.infradead.org" , Andrew Morton , "linuxppc-dev@lists.ozlabs.org" , Mike Rapoport Subject: RE: [PATCH 0/6] Remove usage of list iterator past the loop body Thread-Topic: [PATCH 0/6] Remove usage of list iterator past the loop body Thread-Index: AQHYMjRtYqIeET2JD0yO+p9PX3jHEKy0Bmqg 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> 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: linux-fsdevel@vger.kernel.org From: Dan Carpenter > Sent: 07 March 2022 15:01 > > 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) \ head->next == &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) \ for (item = list_first(head, field); item; \ item = 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). David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)