Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758003Ab3FCVFx (ORCPT ); Mon, 3 Jun 2013 17:05:53 -0400 Received: from longford.logfs.org ([213.229.74.203]:59367 "EHLO longford.logfs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757067Ab3FCVFu (ORCPT ); Mon, 3 Jun 2013 17:05:50 -0400 Date: Mon, 3 Jun 2013 15:36:47 -0400 From: =?utf-8?B?SsO2cm4=?= Engel To: Christoph Hellwig Cc: linux-kernel@vger.kernel.org, Chris Mason , linux-btrfs@vger.kernel.org Subject: Re: [PATCH 0/2] introduce list_for_each_entry_del Message-ID: <20130603193647.GB10200@logfs.org> References: <1370280485-10047-1-git-send-email-joern@logfs.org> <20130603204930.GA28299@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20130603204930.GA28299@infradead.org> User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1096 Lines: 35 On Mon, 3 June 2013 13:49:30 -0700, Christoph Hellwig wrote: > > I can't say I like the structure. > > A list_pop that removes and entry from the head or returns NULL if the > list is empty would lead to nice while loops that are obviously > readable instead. Something like this? #define list_pop(head) \ ({ struct list_head *____pos; \ list_empty(head) ? NULL : (____pos = (head)->next, \ list_del(____pos), ____pos) \ }) #define list_pop_entry(head, type, member) \ ({ struct list_head *____pos; \ list_empty(head) ? NULL : (____pos = (head)->next, \ list_del(____pos), list_entry(____pos, type, member) \ }) Would be fine with me as well. Jörn -- Beware of bugs in the above code; I have only proved it correct, but not tried it. -- Donald Knuth -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/