Re: [PATCH spice-server v2] Remove iterator from list iteration macros

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

 



On 08/21/2017 01:35 PM, Frediano Ziglio wrote:
Avoid to have to declare iterator and pass as an argument.

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>

Ack.

---
  server/display-channel.c | 32 +++++++++++---------------------
  server/display-channel.h |  4 ++--
  server/main-channel.c    | 18 ++++++------------
  server/red-channel.c     | 24 ++++++++----------------
  server/red-channel.h     |  4 ++--
  server/red-client.c      | 19 +++++++------------
  server/red-common.h      | 10 +++++-----
  server/red-worker.c      |  6 ++----
  server/reds-private.h    |  4 ++--
  server/reds.c            | 45 +++++++++++++++------------------------------
  server/stream.c          | 15 +++++----------
  11 files changed, 65 insertions(+), 116 deletions(-)

Changes since v1:
- fix macro concatenation and expansion of __LINE__.

Yes, using another macro (G_PASTE) as an indirection macro works.

Uri.

[keeping only the v2 lines below]

diff --git a/server/red-common.h b/server/red-common.h
index cb459b05..9ff1fd9b 100644
--- a/server/red-common.h
+++ b/server/red-common.h
@@ -81,16 +81,16 @@ typedef struct GListIter {
  } GListIter;
#define GLIST_FOREACH_GENERIC(_list, _iter, _type, _data, _dir) \
-    for (_iter.link = _list; \
+    for (GListIter _iter = { .link = _list }; \
          (_data = (_type *) (_iter.link ? _iter.link->data : NULL), \
           _iter.next = (_iter.link ? _iter.link->_dir : NULL), \
           _iter.link) != NULL; \
           _iter.link = _iter.next)
-#define GLIST_FOREACH(_list, _iter, _type, _data) \
-    GLIST_FOREACH_GENERIC(_list, _iter, _type, _data, next)
+#define GLIST_FOREACH(_list, _type, _data) \
+    GLIST_FOREACH_GENERIC(_list, G_PASTE(_iter_, __LINE__), _type, _data, next)
-#define GLIST_FOREACH_REVERSED(_list, _iter, _type, _data) \
-    GLIST_FOREACH_GENERIC(_list, _iter, _type, _data, prev)
+#define GLIST_FOREACH_REVERSED(_list, _type, _data) \
+    GLIST_FOREACH_GENERIC(_list, G_PASTE(_iter_, __LINE__), _type, _data, prev)
#endif /* RED_COMMON_H_ */
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]