From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L562Y-0002oO-Qr for qemu-devel@nongnu.org; Tue, 25 Nov 2008 17:05:50 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L562Y-0002ny-2M for qemu-devel@nongnu.org; Tue, 25 Nov 2008 17:05:50 -0500 Received: from [199.232.76.173] (port=52830 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L562X-0002nq-Sz for qemu-devel@nongnu.org; Tue, 25 Nov 2008 17:05:49 -0500 Received: from mail-qy0-f20.google.com ([209.85.221.20]:39832) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1L562X-0002FD-B5 for qemu-devel@nongnu.org; Tue, 25 Nov 2008 17:05:49 -0500 Received: by qyk13 with SMTP id 13so444233qyk.10 for ; Tue, 25 Nov 2008 14:05:48 -0800 (PST) Message-ID: <492C76B8.50208@codemonkey.ws> Date: Tue, 25 Nov 2008 16:05:44 -0600 From: Anthony Liguori MIME-Version: 1.0 References: <20081119134857.26075.2417.stgit@mchn012c.ww002.siemens.net> <20081119134857.26075.9428.stgit@mchn012c.ww002.siemens.net> <492429F3.3010202@codemonkey.ws> <492435B9.3010106@siemens.com> <49244376.7020009@codemonkey.ws> <20081120132741.GB11616@shareable.org> <492A916C.9080704@siemens.com> In-Reply-To: <492A916C.9080704@siemens.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 1/2] Add TAILQ_FOREACH_SAFE Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jan Kiszka Cc: qemu-devel@nongnu.org Jan Kiszka wrote: > Jamie Lokier wrote: > >> Anthony Liguori wrote: >> >>> Wouldn't: >>> >>> (var) ? ({ (next_var) = ((var)->field.tqe_next); 1;}) :0; >>> >>> Be equivalent to: >>> >>> (var) ? ((next_var = ((var)->field.tqe_next), var) : var >>> >> Simpler: >> >> (var) && ((next_var) = (var)->field.tqe_next, 1) >> >> > > Yes, indeed! > > Anthony, could you merge this one and its application patch? I need both > of them for my kvm series. > Applied. Thanks. Regards, Anthony Liguori > Jan > > --------------> > > Add TAILQ iterator that allows to safely remove elements while walking > the list. > > Signed-off-by: Jan Kiszka > --- > > sys-queue.h | 5 +++++ > 1 files changed, 5 insertions(+), 0 deletions(-) > > diff --git a/sys-queue.h b/sys-queue.h > index 3d0773e..ad5c8fb 100644 > --- a/sys-queue.h > +++ b/sys-queue.h > @@ -210,6 +210,11 @@ struct { \ > (var); \ > > (var) = ((var)->field.tqe_next)) > > > > +#define TAILQ_FOREACH_SAFE(var, head, field, next_var) \ > > + for ((var) = ((head)->tqh_first); \ > > + (var) && ((next_var) = ((var)->field.tqe_next), 1); \ > > + (var) = (next_var)) > > + > > #define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ > > for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \ > > (var); \ > > >