Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com> writes: > Add QLIST_FOREACH_FUNC_SAFE(), QTAILQ_FOREACH_FUNC_SAFE() and > QTAILQ_POP_HEAD(), to be used in following commit. > > Signed-off-by: Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com> > --- > include/qemu/queue.h | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/include/qemu/queue.h b/include/qemu/queue.h > index e029e7bf66..03e1fce85f 100644 > --- a/include/qemu/queue.h > +++ b/include/qemu/queue.h > @@ -173,6 +173,13 @@ struct { > \ > (var) && ((next_var) = ((var)->field.le_next), 1); \ > (var) = (next_var)) > > +#define QLIST_FOREACH_FUNC_SAFE(head, field, func) do { \ > + typeof(*QLIST_FIRST(head)) *qffs_var, *qffs_next_var; \ > + QLIST_FOREACH_SAFE(qffs_var, (head), field, qffs_next_var) { \ > + (func)(qffs_var); \ > + } \ > +} while (/*CONSTCOND*/0) > + > /* > * List access methods. > */ > @@ -490,6 +497,13 @@ union { > \ > (var) && ((prev_var) = QTAILQ_PREV(var, field), 1); \ > (var) = (prev_var)) > > +#define QTAILQ_FOREACH_FUNC_SAFE(head, field, func) do { \ > + typeof(*QTAILQ_FIRST(head)) *qffs_var, *qffs_next_var; \ > + QTAILQ_FOREACH_SAFE(qffs_var, (head), field, qffs_next_var) { \ > + (func)(qffs_var); \ > + } \ > +} while (/*CONSTCOND*/0) > + > /* > * Tail queue access methods. > */
I wonder whether these are worth having. Can you show the difference they make in the next patch?