[Spice-devel] [server PATCH 6/8] red_worker: make CCC_FOREACH safe
Uri Lublin
uril at redhat.com
Mon Jul 8 03:32:28 PDT 2013
Even though it is not used, it's better to make it safe (or remove it).
---
server/red_worker.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/server/red_worker.c b/server/red_worker.c
index 72e5ea5..1f239c5 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -1157,12 +1157,14 @@ static inline uint64_t red_now(void);
(next) = (link) ? ring_next(&drawable->glz_ring, (link)) : NULL,\
glz = (link) ? SPICE_CONTAINEROF((link), RedGlzDrawable, drawable_link) : NULL)
-#define CCC_FOREACH(link, ccc, channel) \
+#define CCC_FOREACH_SAFE(link, next, ccc, channel) \
for (link = ring_get_head(&(channel)->clients),\
- ccc = SPICE_CONTAINEROF(link, CommonChannelClient, base.channel_link);\
- (link); \
- (link) = ring_next(&(channel)->clients, link),\
- ccc = SPICE_CONTAINEROF(link, CommonChannelClient, base.channel_link))
+ (next) = (link) ? ring_next(&(channel)->clients, (link)) : NULL, \
+ ccc = SPICE_CONTAINEROF(link, CommonChannelClient, base.channel_link);\
+ (link); \
+ (link) = (next), \
+ (next) = (link) ? ring_next(&(channel)->clients, (link)) : NULL, \
+ ccc = SPICE_CONTAINEROF(link, CommonChannelClient, base.channel_link))
#define DCC_TO_WORKER(dcc) \
(SPICE_CONTAINEROF((dcc)->common.base.channel, CommonChannel, base)->worker)
--
1.7.1
More information about the Spice-devel
mailing list