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 40155C433F5 for ; Tue, 8 Mar 2022 15:16:02 +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 8027917EA; Tue, 8 Mar 2022 16:15:10 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8027917EA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1646752560; bh=oUhrbeOcgLGATYXaOidB+QuDF9AXqLOcyt6Py5uhLno=; h=From:To:Subject:Date:References:In-Reply-To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=HY94tedNz87lg/5/fy9FQn5IczdnZ7+yQKMISCp7JBbz/gdZ0XHqnAggwr3peUuiL v77/2DbuNtx5ZodWSJqSPB1MNdNqP7QTDA1roiQyDMRA2L8+brsTYa/RgzmuB2rWMH cOY1T/9+fqyZwDPRlUJZ5teXwYSXKmRyciYakXWU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 27EBAF80535; Tue, 8 Mar 2022 16:12:51 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 27CDAF8020D; Mon, 7 Mar 2022 16:27:02 +0100 (CET) Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.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 C07DEF80124 for ; Mon, 7 Mar 2022 16:26:54 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C07DEF80124 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 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: quoted-printable X-Mailman-Approved-At: Tue, 08 Mar 2022 16:12:38 +0100 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 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: 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)