qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/7] qemu/queue: add some useful QLIST_ and QTAILQ_ macros


From: Vladimir Sementsov-Ogievskiy
Subject: Re: [PATCH 1/7] qemu/queue: add some useful QLIST_ and QTAILQ_ macros
Date: Mon, 1 Feb 2021 11:34:44 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0

01.02.2021 11:29, Markus Armbruster wrote:
Vladimir Sementsov-Ogievskiy <vsementsov@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 <vsementsov@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?


Not big difference, so I can easily drop them. But I think it's a good idea and 
can be reused.. Why don't you like it?

--
Best regards,
Vladimir



reply via email to

[Prev in Thread] Current Thread [Next in Thread]