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 814D9C433F5 for ; Mon, 7 Mar 2022 15:27:14 +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 1nRFGV-0007eO-0r; Mon, 07 Mar 2022 15:27:13 +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 1nRFGM-0007YL-8C for linux-f2fs-devel@lists.sourceforge.net; Mon, 07 Mar 2022 15:27:04 +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=s7gqaLotuvbOoG2TIKRqvzdLLz0csANWn0PyiegDKZE=; b=InOXsBjWmdxP+fISsgrxaXkmMw QBcb6K7f8VDAC/C+hgHyD+np3j/ErH54OuO9yKt42xnGYDiOHytcw0qkfhziR4Ji19rVnElFLtfJT Ys3A+jtgFwgh/lk51hsY962HFNdZbVzWkLsxFyDhHbDwH8NKOGng4FuHxiDUg3jk5JKc=; 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=s7gqaLotuvbOoG2TIKRqvzdLLz0csANWn0PyiegDKZE=; b=OVHF1kDb4fpacFNG1ont0qnL42 ysxwHx5dP/Gqw/RPGM4FKICB/BfhoD2WSrzioteTsvWJOxMSFgS8BMMlPpC12YoU1VthYZB7WIyKR dG2J2QCw7VzxRqvySyY6QqJ4tbCyPXXRcW1Lk8LNFYlCyMcPBnXwA8WWa06X8ztDtI9c=; Received: from eu-smtp-delivery-151.mimecast.com ([185.58.86.151]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.94.2) id 1nRFGJ-0001tm-PO for linux-f2fs-devel@lists.sourceforge.net; Mon, 07 Mar 2022 15:27:04 +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-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 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 X-Headers-End: 1nRFGJ-0001tm-PO Subject: Re: [f2fs-dev] [PATCH 0/6] Remove usage of list iterator past the loop body 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: "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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net 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) _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel