[Spice-devel] [PATCH spice-server v2] Remove iterator from list iteration macros
Frediano Ziglio
fziglio at redhat.com
Mon Aug 21 10:35:36 UTC 2017
Avoid to have to declare iterator and pass as an argument.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
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__.
diff --git a/server/display-channel.c b/server/display-channel.c
index 68ea3bad..924d219b 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -256,7 +256,6 @@ void display_channel_surface_unref(DisplayChannel *display, uint32_t surface_id)
RedSurface *surface = &display->priv->surfaces[surface_id];
QXLInstance *qxl = common_graphics_channel_get_qxl(COMMON_GRAPHICS_CHANNEL(display));
DisplayChannelClient *dcc;
- GListIter iter;
if (--surface->refs != 0) {
return;
@@ -278,7 +277,7 @@ void display_channel_surface_unref(DisplayChannel *display, uint32_t surface_id)
region_destroy(&surface->draw_dirty_region);
surface->context.canvas = NULL;
- FOREACH_DCC(display, iter, dcc) {
+ FOREACH_DCC(display, dcc) {
dcc_destroy_surface(dcc, surface_id);
}
@@ -296,7 +295,6 @@ static void streams_update_visible_region(DisplayChannel *display, Drawable *dra
{
Ring *ring;
RingItem *item;
- GListIter iter;
DisplayChannelClient *dcc;
if (!red_channel_is_connected(RED_CHANNEL(display))) {
@@ -320,7 +318,7 @@ static void streams_update_visible_region(DisplayChannel *display, Drawable *dra
continue;
}
- FOREACH_DCC(display, iter, dcc) {
+ FOREACH_DCC(display, dcc) {
agent = dcc_get_stream_agent(dcc, display_channel_get_stream_id(display, stream));
if (region_intersects(&agent->vis_region, &drawable->tree_item.base.rgn)) {
@@ -335,10 +333,9 @@ static void streams_update_visible_region(DisplayChannel *display, Drawable *dra
static void pipes_add_drawable(DisplayChannel *display, Drawable *drawable)
{
DisplayChannelClient *dcc;
- GListIter iter;
spice_warn_if_fail(drawable->pipes == NULL);
- FOREACH_DCC(display, iter, dcc) {
+ FOREACH_DCC(display, dcc) {
dcc_prepend_drawable(dcc, drawable);
}
}
@@ -363,9 +360,8 @@ static void pipes_add_drawable_after(DisplayChannel *display,
return;
}
if (num_other_linked != red_channel_get_n_clients(RED_CHANNEL(display))) {
- GListIter iter;
spice_debug("TODO: not O(n^2)");
- FOREACH_DCC(display, iter, dcc) {
+ FOREACH_DCC(display, dcc) {
int sent = 0;
GList *l;
for (l = pos_after->pipes; l != NULL; l = l->next) {
@@ -546,7 +542,6 @@ static bool current_add_equal(DisplayChannel *display, DrawItem *item, TreeItem
DisplayChannelClient *dcc;
GList *dpi_item;
- GListIter iter;
other_drawable->refs++;
current_remove_drawable(display, other_drawable);
@@ -555,7 +550,7 @@ static bool current_add_equal(DisplayChannel *display, DrawItem *item, TreeItem
* (or will receive) other_drawable */
dpi_item = g_list_first(other_drawable->pipes);
/* dpi contains a sublist of dcc's, ordered the same */
- FOREACH_DCC(display, iter, dcc) {
+ FOREACH_DCC(display, dcc) {
if (dpi_item && dcc == ((RedDrawablePipeItem *) dpi_item->data)->dcc) {
dpi_item = dpi_item->next;
} else {
@@ -1481,24 +1476,22 @@ void display_channel_flush_all_surfaces(DisplayChannel *display)
void display_channel_free_glz_drawables_to_free(DisplayChannel *display)
{
- GListIter iter;
DisplayChannelClient *dcc;
spice_return_if_fail(display);
- FOREACH_DCC(display, iter, dcc) {
+ FOREACH_DCC(display, dcc) {
image_encoders_free_glz_drawables_to_free(dcc_get_encoders(dcc));
}
}
void display_channel_free_glz_drawables(DisplayChannel *display)
{
- GListIter iter;
DisplayChannelClient *dcc;
spice_return_if_fail(display);
- FOREACH_DCC(display, iter, dcc) {
+ FOREACH_DCC(display, dcc) {
image_encoders_free_glz_drawables(dcc_get_encoders(dcc));
}
}
@@ -1537,11 +1530,10 @@ void display_channel_free_some(DisplayChannel *display)
{
int n = 0;
DisplayChannelClient *dcc;
- GListIter iter;
spice_debug("#draw=%d, #glz_draw=%d", display->priv->drawable_count,
display->priv->encoder_shared_data.glz_drawable_count);
- FOREACH_DCC(display, iter, dcc) {
+ FOREACH_DCC(display, dcc) {
ImageEncoders *encoders = dcc_get_encoders(dcc);
// encoding using the dictionary is prevented since the following operations might
@@ -1555,7 +1547,7 @@ void display_channel_free_some(DisplayChannel *display)
free_one_drawable(display, TRUE);
}
- FOREACH_DCC(display, iter, dcc) {
+ FOREACH_DCC(display, dcc) {
ImageEncoders *encoders = dcc_get_encoders(dcc);
image_encoders_glz_encode_unlock(encoders);
@@ -2028,10 +2020,9 @@ void display_channel_update(DisplayChannel *display,
static void clear_surface_drawables_from_pipes(DisplayChannel *display, int surface_id,
int wait_if_used)
{
- GListIter iter;
DisplayChannelClient *dcc;
- FOREACH_DCC(display, iter, dcc) {
+ FOREACH_DCC(display, dcc) {
if (!dcc_clear_surface_drawables_from_pipe(dcc, surface_id, wait_if_used)) {
red_channel_client_disconnect(RED_CHANNEL_CLIENT(dcc));
}
@@ -2095,9 +2086,8 @@ void display_channel_destroy_surfaces(DisplayChannel *display)
static void send_create_surface(DisplayChannel *display, int surface_id, int image_ready)
{
DisplayChannelClient *dcc;
- GListIter iter;
- FOREACH_DCC(display, iter, dcc) {
+ FOREACH_DCC(display, dcc) {
dcc_create_surface(dcc, surface_id);
if (image_ready)
dcc_push_surface_image(dcc, surface_id);
diff --git a/server/display-channel.h b/server/display-channel.h
index d15aad46..01e3621e 100644
--- a/server/display-channel.h
+++ b/server/display-channel.h
@@ -179,9 +179,9 @@ typedef struct RedSurface {
QXLReleaseInfoExt create, destroy;
} RedSurface;
-#define FOREACH_DCC(_channel, _iter, _data) \
+#define FOREACH_DCC(_channel, _data) \
GLIST_FOREACH((_channel ? red_channel_get_clients(RED_CHANNEL(_channel)) : NULL), \
- _iter, DisplayChannelClient, _data)
+ DisplayChannelClient, _data)
int display_channel_get_stream_id(DisplayChannel *display, Stream *stream);
Stream *display_channel_get_nth_stream(DisplayChannel *display, gint i);
diff --git a/server/main-channel.c b/server/main-channel.c
index e9fef7c1..5aaba0ab 100644
--- a/server/main-channel.c
+++ b/server/main-channel.c
@@ -62,10 +62,9 @@ static void main_channel_client_on_disconnect(RedChannelClient *rcc)
RedClient *main_channel_get_client_by_link_id(MainChannel *main_chan, uint32_t connection_id)
{
- GListIter iter;
RedChannelClient *rcc;
- FOREACH_CLIENT(main_chan, iter, rcc) {
+ FOREACH_CLIENT(main_chan, rcc) {
MainChannelClient *mcc = MAIN_CHANNEL_CLIENT(rcc);
if (main_channel_client_get_connection_id(mcc) == connection_id) {
return red_channel_client_get_client(rcc);
@@ -99,9 +98,8 @@ void main_channel_push_mouse_mode(MainChannel *main_chan, int current_mode,
void main_channel_push_agent_connected(MainChannel *main_chan)
{
- GListIter iter;
RedChannelClient *rcc;
- FOREACH_CLIENT(RED_CHANNEL(main_chan), iter, rcc) {
+ FOREACH_CLIENT(RED_CHANNEL(main_chan), rcc) {
if (red_channel_client_test_remote_cap(rcc,
SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS)) {
red_channel_client_pipe_add_type(rcc,
@@ -325,10 +323,9 @@ main_channel_class_init(MainChannelClass *klass)
static int main_channel_connect_semi_seamless(MainChannel *main_channel)
{
- GListIter iter;
RedChannelClient *rcc;
- FOREACH_CLIENT(main_channel, iter, rcc) {
+ FOREACH_CLIENT(main_channel, rcc) {
MainChannelClient *mcc = MAIN_CHANNEL_CLIENT(rcc);
if (main_channel_client_connect_semi_seamless(mcc))
main_channel->num_clients_mig_wait++;
@@ -338,12 +335,11 @@ static int main_channel_connect_semi_seamless(MainChannel *main_channel)
static int main_channel_connect_seamless(MainChannel *main_channel)
{
- GListIter iter;
RedChannelClient *rcc;
spice_assert(red_channel_get_n_clients(RED_CHANNEL(main_channel)) == 1);
- FOREACH_CLIENT(main_channel, iter, rcc) {
+ FOREACH_CLIENT(main_channel, rcc) {
MainChannelClient *mcc = MAIN_CHANNEL_CLIENT(rcc);
main_channel_client_connect_seamless(mcc);
main_channel->num_clients_mig_wait++;
@@ -382,10 +378,9 @@ int main_channel_migrate_connect(MainChannel *main_channel, RedsMigSpice *mig_ta
void main_channel_migrate_cancel_wait(MainChannel *main_chan)
{
- GListIter iter;
RedChannelClient *rcc;
- FOREACH_CLIENT(main_chan, iter, rcc) {
+ FOREACH_CLIENT(main_chan, rcc) {
MainChannelClient *mcc = MAIN_CHANNEL_CLIENT(rcc);
main_channel_client_migrate_cancel_wait(mcc);
}
@@ -394,7 +389,6 @@ void main_channel_migrate_cancel_wait(MainChannel *main_chan)
int main_channel_migrate_src_complete(MainChannel *main_chan, int success)
{
- GListIter iter;
int semi_seamless_count = 0;
RedChannelClient *rcc;
@@ -405,7 +399,7 @@ int main_channel_migrate_src_complete(MainChannel *main_chan, int success)
return 0;
}
- FOREACH_CLIENT(main_chan, iter, rcc) {
+ FOREACH_CLIENT(main_chan, rcc) {
MainChannelClient *mcc = MAIN_CHANNEL_CLIENT(rcc);
if (main_channel_client_migrate_src_complete(mcc, success))
semi_seamless_count++;
diff --git a/server/red-channel.c b/server/red-channel.c
index 9bd98234..9559547c 100644
--- a/server/red-channel.c
+++ b/server/red-channel.c
@@ -316,10 +316,9 @@ void red_channel_add_client(RedChannel *channel, RedChannelClient *rcc)
bool red_channel_test_remote_cap(RedChannel *channel, uint32_t cap)
{
- GListIter iter;
RedChannelClient *rcc;
- FOREACH_CLIENT(channel, iter, rcc) {
+ FOREACH_CLIENT(channel, rcc) {
if (!red_channel_client_test_remote_cap(rcc, cap)) {
return FALSE;
}
@@ -511,13 +510,12 @@ guint red_channel_get_n_clients(RedChannel *channel)
bool red_channel_all_blocked(RedChannel *channel)
{
- GListIter iter;
RedChannelClient *rcc;
if (!channel || !channel->priv->clients) {
return FALSE;
}
- FOREACH_CLIENT(channel, iter, rcc) {
+ FOREACH_CLIENT(channel, rcc) {
if (!red_channel_client_is_blocked(rcc)) {
return FALSE;
}
@@ -528,10 +526,9 @@ bool red_channel_all_blocked(RedChannel *channel)
/* return TRUE if any of the connected clients to this channel are blocked */
static bool red_channel_any_blocked(RedChannel *channel)
{
- GListIter iter;
RedChannelClient *rcc;
- FOREACH_CLIENT(channel, iter, rcc) {
+ FOREACH_CLIENT(channel, rcc) {
if (red_channel_client_is_blocked(rcc)) {
return TRUE;
}
@@ -541,10 +538,9 @@ static bool red_channel_any_blocked(RedChannel *channel)
static bool red_channel_no_item_being_sent(RedChannel *channel)
{
- GListIter iter;
RedChannelClient *rcc;
- FOREACH_CLIENT(channel, iter, rcc) {
+ FOREACH_CLIENT(channel, rcc) {
if (!red_channel_client_no_item_being_sent(rcc)) {
return FALSE;
}
@@ -578,7 +574,6 @@ static int red_channel_pipes_create_batch(RedChannel *channel,
new_pipe_item_t creator, void *data,
rcc_item_t pipe_add)
{
- GListIter iter;
RedChannelClient *rcc;
RedPipeItem *item;
int num = 0, n = 0;
@@ -586,7 +581,7 @@ static int red_channel_pipes_create_batch(RedChannel *channel,
spice_assert(creator != NULL);
spice_assert(pipe_add != NULL);
- FOREACH_CLIENT(channel, iter, rcc) {
+ FOREACH_CLIENT(channel, rcc) {
item = (*creator)(rcc, data, num++);
if (item) {
(*pipe_add)(rcc, item);
@@ -615,11 +610,10 @@ void red_channel_pipes_new_add(RedChannel *channel, new_pipe_item_t creator, voi
uint32_t red_channel_max_pipe_size(RedChannel *channel)
{
- GListIter iter;
RedChannelClient *rcc;
uint32_t pipe_size = 0;
- FOREACH_CLIENT(channel, iter, rcc) {
+ FOREACH_CLIENT(channel, rcc) {
uint32_t new_size;
new_size = red_channel_client_get_pipe_size(rcc);
pipe_size = MAX(pipe_size, new_size);
@@ -629,11 +623,10 @@ uint32_t red_channel_max_pipe_size(RedChannel *channel)
uint32_t red_channel_min_pipe_size(RedChannel *channel)
{
- GListIter iter;
RedChannelClient *rcc;
uint32_t pipe_size = ~0;
- FOREACH_CLIENT(channel, iter, rcc) {
+ FOREACH_CLIENT(channel, rcc) {
uint32_t new_size;
new_size = red_channel_client_get_pipe_size(rcc);
pipe_size = MIN(pipe_size, new_size);
@@ -643,11 +636,10 @@ uint32_t red_channel_min_pipe_size(RedChannel *channel)
uint32_t red_channel_sum_pipes_size(RedChannel *channel)
{
- GListIter iter;
RedChannelClient *rcc;
uint32_t sum = 0;
- FOREACH_CLIENT(channel, iter, rcc) {
+ FOREACH_CLIENT(channel, rcc) {
sum += red_channel_client_get_pipe_size(rcc);
}
return sum;
diff --git a/server/red-channel.h b/server/red-channel.h
index a9088a7d..e65eea1e 100644
--- a/server/red-channel.h
+++ b/server/red-channel.h
@@ -122,9 +122,9 @@ struct RedChannelClass
channel_handle_migrate_data_get_serial_proc handle_migrate_data_get_serial;
};
-#define FOREACH_CLIENT(_channel, _iter, _data) \
+#define FOREACH_CLIENT(_channel, _data) \
GLIST_FOREACH((_channel ? red_channel_get_clients(RED_CHANNEL(_channel)) : NULL), \
- _iter, RedChannelClient, _data)
+ RedChannelClient, _data)
/* Red Channel interface */
diff --git a/server/red-client.c b/server/red-client.c
index b783b84c..666903e3 100644
--- a/server/red-client.c
+++ b/server/red-client.c
@@ -23,8 +23,8 @@
#include "red-client.h"
#include "reds.h"
-#define FOREACH_CHANNEL_CLIENT(_client, _iter, _data) \
- GLIST_FOREACH((_client ? (_client)->channels : NULL), _iter, RedChannelClient, _data)
+#define FOREACH_CHANNEL_CLIENT(_client, _data) \
+ GLIST_FOREACH((_client ? (_client)->channels : NULL), RedChannelClient, _data)
struct RedClient {
GObject parent;
@@ -155,7 +155,6 @@ RedClient *red_client_new(RedsState *reds, int migrated)
void red_client_set_migration_seamless(RedClient *client) // dest
{
- GListIter iter;
RedChannelClient *rcc;
spice_assert(client->during_target_migrate);
@@ -163,7 +162,7 @@ void red_client_set_migration_seamless(RedClient *client) // dest
client->seamless_migrate = TRUE;
/* update channel clients that got connected before the migration
* type was set. red_client_add_channel will handle newer channel clients */
- FOREACH_CHANNEL_CLIENT(client, iter, rcc) {
+ FOREACH_CHANNEL_CLIENT(client, rcc) {
if (red_channel_client_set_migration_seamless(rcc)) {
client->num_migrated_channels++;
}
@@ -173,7 +172,6 @@ void red_client_set_migration_seamless(RedClient *client) // dest
void red_client_migrate(RedClient *client)
{
- GListIter iter;
RedChannelClient *rcc;
RedChannel *channel;
@@ -184,7 +182,7 @@ void red_client_migrate(RedClient *client)
" this might be a BUG",
client->thread_id, pthread_self());
}
- FOREACH_CHANNEL_CLIENT(client, iter, rcc) {
+ FOREACH_CHANNEL_CLIENT(client, rcc) {
if (red_channel_client_is_connected(rcc)) {
channel = red_channel_client_get_channel(rcc);
red_channel_migrate_client(channel, rcc);
@@ -194,7 +192,6 @@ void red_client_migrate(RedClient *client)
void red_client_destroy(RedClient *client)
{
- GListIter iter;
RedChannelClient *rcc;
spice_printerr("destroy client %p with #channels=%d", client, g_list_length(client->channels));
@@ -205,7 +202,7 @@ void red_client_destroy(RedClient *client)
client->thread_id,
pthread_self());
}
- FOREACH_CHANNEL_CLIENT(client, iter, rcc) {
+ FOREACH_CHANNEL_CLIENT(client, rcc) {
RedChannel *channel;
// some channels may be in other threads, so disconnection
// is not synchronous.
@@ -228,11 +225,10 @@ void red_client_destroy(RedClient *client)
/* client->lock should be locked */
static RedChannelClient *red_client_get_channel(RedClient *client, int type, int id)
{
- GListIter iter;
RedChannelClient *rcc;
RedChannelClient *ret = NULL;
- FOREACH_CHANNEL_CLIENT(client, iter, rcc) {
+ FOREACH_CHANNEL_CLIENT(client, rcc) {
int channel_type, channel_id;
RedChannel *channel;
@@ -292,7 +288,6 @@ void red_client_set_main(RedClient *client, MainChannelClient *mcc)
void red_client_semi_seamless_migrate_complete(RedClient *client)
{
- GListIter iter;
RedChannelClient *rcc;
pthread_mutex_lock(&client->lock);
@@ -302,7 +297,7 @@ void red_client_semi_seamless_migrate_complete(RedClient *client)
return;
}
client->during_target_migrate = FALSE;
- FOREACH_CHANNEL_CLIENT(client, iter, rcc) {
+ FOREACH_CHANNEL_CLIENT(client, rcc) {
red_channel_client_semi_seamless_migration_complete(rcc);
}
pthread_mutex_unlock(&client->lock);
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_ */
diff --git a/server/red-worker.c b/server/red-worker.c
index f747e128..36a29074 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -380,7 +380,6 @@ static void guest_set_client_capabilities(RedWorker *worker)
{
int i;
RedChannelClient *rcc;
- GListIter iter;
uint8_t caps[SPICE_CAPABILITIES_SIZE] = { 0 };
int caps_available[] = {
SPICE_DISPLAY_CAP_SIZED_STREAM,
@@ -413,7 +412,7 @@ static void guest_set_client_capabilities(RedWorker *worker)
for (i = 0 ; i < SPICE_N_ELEMENTS(caps_available); ++i) {
SET_CAP(caps, caps_available[i]);
}
- FOREACH_CLIENT(worker->display_channel, iter, rcc) {
+ FOREACH_CLIENT(worker->display_channel, rcc) {
for (i = 0 ; i < SPICE_N_ELEMENTS(caps_available); ++i) {
if (!red_channel_client_test_remote_cap(rcc, caps_available[i]))
CLEAR_CAP(caps, caps_available[i]);
@@ -489,9 +488,8 @@ static void handle_dev_destroy_surfaces(void *opaque, void *payload)
static void red_worker_push_monitors_config(RedWorker *worker)
{
DisplayChannelClient *dcc;
- GListIter iter;
- FOREACH_DCC(worker->display_channel, iter, dcc) {
+ FOREACH_DCC(worker->display_channel, dcc) {
dcc_push_monitors_config(dcc);
}
}
diff --git a/server/reds-private.h b/server/reds-private.h
index 26b7435a..c4ab3d1c 100644
--- a/server/reds-private.h
+++ b/server/reds-private.h
@@ -134,7 +134,7 @@ struct RedsState {
RedRecord *record;
};
-#define FOREACH_QXL_INSTANCE(_reds, _iter, _qxl) \
- GLIST_FOREACH(_reds->qxl_instances, _iter, QXLInstance, _qxl)
+#define FOREACH_QXL_INSTANCE(_reds, _qxl) \
+ GLIST_FOREACH(_reds->qxl_instances, QXLInstance, _qxl)
#endif /* REDS_PRIVATE_H_ */
diff --git a/server/reds.c b/server/reds.c
index 8abfbda5..33f038c7 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -400,10 +400,9 @@ void reds_unregister_channel(RedsState *reds, RedChannel *channel)
RedChannel *reds_find_channel(RedsState *reds, uint32_t type, uint32_t id)
{
- GListIter it;
RedChannel *channel;
- GLIST_FOREACH(reds->channels, it, RedChannel, channel) {
+ GLIST_FOREACH(reds->channels, RedChannel, channel) {
uint32_t this_type, this_id;
g_object_get(channel, "channel-type", &this_type, "id", &this_id, NULL);
if (this_type == type && this_id == id) {
@@ -574,11 +573,10 @@ void reds_client_disconnect(RedsState *reds, RedClient *client)
// reds_client_disconnect
static void reds_disconnect(RedsState *reds)
{
- GListIter iter;
RedClient *client;
spice_debug("trace");
- GLIST_FOREACH(reds->clients, iter, RedClient, client) {
+ GLIST_FOREACH(reds->clients, RedClient, client) {
reds_client_disconnect(reds, client);
}
reds_mig_cleanup(reds);
@@ -605,7 +603,6 @@ int reds_get_mouse_mode(RedsState *reds)
static void reds_set_mouse_mode(RedsState *reds, uint32_t mode)
{
- GListIter it;
QXLInstance *qxl;
if (reds->mouse_mode == mode) {
@@ -613,7 +610,7 @@ static void reds_set_mouse_mode(RedsState *reds, uint32_t mode)
}
reds->mouse_mode = mode;
- FOREACH_QXL_INSTANCE(reds, it, qxl) {
+ FOREACH_QXL_INSTANCE(reds, qxl) {
red_qxl_set_mouse_mode(qxl, mode);
}
@@ -957,11 +954,10 @@ static bool channel_supports_multiple_clients(RedChannel *channel)
static void reds_fill_channels(RedsState *reds, SpiceMsgChannels *channels_info)
{
- GListIter it;
RedChannel *channel;
int used_channels = 0;
- GLIST_FOREACH(reds->channels, it, RedChannel, channel) {
+ GLIST_FOREACH(reds->channels, RedChannel, channel) {
uint32_t type, id;
if (g_list_length(reds->clients) > 1 &&
!channel_supports_multiple_clients(channel)) {
@@ -1689,20 +1685,18 @@ static void reds_mig_target_client_free(RedsState *reds, RedsMigTargetClient *mi
static void reds_mig_target_client_disconnect_all(RedsState *reds)
{
- GListIter it;
RedsMigTargetClient *mig_client;
- GLIST_FOREACH(reds->mig_target_clients, it, RedsMigTargetClient, mig_client) {
+ GLIST_FOREACH(reds->mig_target_clients, RedsMigTargetClient, mig_client) {
reds_client_disconnect(reds, mig_client->client);
}
}
static bool reds_find_client(RedsState *reds, RedClient *client)
{
- GListIter iter;
RedClient *list_client;
- GLIST_FOREACH(reds->clients, iter, RedClient, list_client) {
+ GLIST_FOREACH(reds->clients, RedClient, list_client) {
if (list_client == client) {
return TRUE;
}
@@ -2964,13 +2958,12 @@ static void reds_mig_started(RedsState *reds)
static void reds_mig_fill_wait_disconnect(RedsState *reds)
{
- GListIter iter;
RedClient *client;
spice_assert(reds->clients != NULL);
/* tracking the clients, in order to ignore disconnection
* of clients that got connected to the src after migration completion.*/
- GLIST_FOREACH(reds->clients, iter, RedClient, client) {
+ GLIST_FOREACH(reds->clients, RedClient, client) {
reds->mig_wait_disconnect_clients = g_list_append(reds->mig_wait_disconnect_clients, client);
}
reds->mig_wait_connect = FALSE;
@@ -4355,11 +4348,10 @@ void reds_update_client_mouse_allowed(RedsState *reds)
int num_active_workers = g_list_length(reds->qxl_instances);
if (num_active_workers > 0) {
- GListIter it;
QXLInstance *qxl;
allow_now = TRUE;
- FOREACH_QXL_INSTANCE(reds, it, qxl) {
+ FOREACH_QXL_INSTANCE(reds, qxl) {
if (red_qxl_get_primary_active(qxl)) {
allow_now = red_qxl_get_allow_client_mouse(qxl, &x_res, &y_res);
break;
@@ -4380,14 +4372,13 @@ void reds_update_client_mouse_allowed(RedsState *reds)
static gboolean reds_use_client_monitors_config(RedsState *reds)
{
- GListIter it;
QXLInstance *qxl;
if (reds->qxl_instances == NULL) {
return FALSE;
}
- FOREACH_QXL_INSTANCE(reds, it, qxl) {
+ FOREACH_QXL_INSTANCE(reds, qxl) {
if (!red_qxl_use_client_monitors_config(qxl))
return FALSE;
}
@@ -4396,10 +4387,9 @@ static gboolean reds_use_client_monitors_config(RedsState *reds)
static void reds_client_monitors_config(RedsState *reds, VDAgentMonitorsConfig *monitors_config)
{
- GListIter it;
QXLInstance *qxl;
- FOREACH_QXL_INSTANCE(reds, it, qxl) {
+ FOREACH_QXL_INSTANCE(reds, qxl) {
if (!red_qxl_client_monitors_config(qxl, monitors_config)) {
/* this is a normal condition, some qemu devices might not implement it */
spice_debug("QXLInterface::client_monitors_config failed\n");
@@ -4422,10 +4412,9 @@ static int calc_compression_level(RedsState *reds)
void reds_on_ic_change(RedsState *reds)
{
int compression_level = calc_compression_level(reds);
- GListIter it;
QXLInstance *qxl;
- FOREACH_QXL_INSTANCE(reds, it, qxl) {
+ FOREACH_QXL_INSTANCE(reds, qxl) {
red_qxl_set_compression_level(qxl, compression_level);
red_qxl_on_ic_change(qxl, spice_server_get_image_compression(reds));
}
@@ -4434,10 +4423,9 @@ void reds_on_ic_change(RedsState *reds)
void reds_on_sv_change(RedsState *reds)
{
int compression_level = calc_compression_level(reds);
- GListIter it;
QXLInstance *qxl;
- FOREACH_QXL_INSTANCE(reds, it, qxl) {
+ FOREACH_QXL_INSTANCE(reds, qxl) {
red_qxl_set_compression_level(qxl, compression_level);
red_qxl_on_sv_change(qxl, reds_get_streaming_video(reds));
}
@@ -4445,30 +4433,27 @@ void reds_on_sv_change(RedsState *reds)
void reds_on_vc_change(RedsState *reds)
{
- GListIter it;
QXLInstance *qxl;
- FOREACH_QXL_INSTANCE(reds, it, qxl) {
+ FOREACH_QXL_INSTANCE(reds, qxl) {
red_qxl_on_vc_change(qxl, reds_get_video_codecs(reds));
}
}
void reds_on_vm_stop(RedsState *reds)
{
- GListIter it;
QXLInstance *qxl;
- FOREACH_QXL_INSTANCE(reds, it, qxl) {
+ FOREACH_QXL_INSTANCE(reds, qxl) {
red_qxl_stop(qxl);
}
}
void reds_on_vm_start(RedsState *reds)
{
- GListIter it;
QXLInstance *qxl;
- FOREACH_QXL_INSTANCE(reds, it, qxl) {
+ FOREACH_QXL_INSTANCE(reds, qxl) {
red_qxl_start(qxl);
}
}
diff --git a/server/stream.c b/server/stream.c
index ff2676cf..f74a1385 100644
--- a/server/stream.c
+++ b/server/stream.c
@@ -98,13 +98,12 @@ static RedPipeItem *stream_destroy_item_new(StreamAgent *agent)
void stream_stop(DisplayChannel *display, Stream *stream)
{
DisplayChannelClient *dcc;
- GListIter iter;
spice_return_if_fail(ring_item_is_linked(&stream->link));
spice_return_if_fail(!stream->current);
spice_debug("stream %d", display_channel_get_stream_id(display, stream));
- FOREACH_DCC(display, iter, dcc) {
+ FOREACH_DCC(display, dcc) {
StreamAgent *stream_agent;
stream_agent = dcc_get_stream_agent(dcc, display_channel_get_stream_id(display, stream));
@@ -281,7 +280,6 @@ static bool is_next_stream_frame(DisplayChannel *display,
static void attach_stream(DisplayChannel *display, Drawable *drawable, Stream *stream)
{
DisplayChannelClient *dcc;
- GListIter iter;
spice_assert(drawable && stream);
spice_assert(!drawable->stream && !stream->current);
@@ -300,7 +298,7 @@ static void attach_stream(DisplayChannel *display, Drawable *drawable, Stream *s
stream->num_input_frames++;
}
- FOREACH_DCC(display, iter, dcc) {
+ FOREACH_DCC(display, dcc) {
StreamAgent *agent;
QRegion clip_in_draw_dest;
@@ -381,7 +379,6 @@ static Stream *display_channel_stream_try_new(DisplayChannel *display)
static void display_channel_create_stream(DisplayChannel *display, Drawable *drawable)
{
DisplayChannelClient *dcc;
- GListIter iter;
Stream *stream;
SpiceRect* src_rect;
@@ -418,7 +415,7 @@ static void display_channel_create_stream(DisplayChannel *display, Drawable *dra
stream->input_fps_start_time = drawable->creation_time;
display->priv->streams_size_total += stream->width * stream->height;
display->priv->stream_count++;
- FOREACH_DCC(display, iter, dcc) {
+ FOREACH_DCC(display, dcc) {
dcc_create_stream(dcc, stream);
}
spice_debug("stream %d %dx%d (%d, %d) (%d, %d) %u fps",
@@ -856,10 +853,9 @@ clear_vis_region:
static void detach_stream_gracefully(DisplayChannel *display, Stream *stream,
Drawable *update_area_limit)
{
- GListIter iter;
DisplayChannelClient *dcc;
- FOREACH_DCC(display, iter, dcc) {
+ FOREACH_DCC(display, dcc) {
dcc_detach_stream_gracefully(dcc, stream, update_area_limit);
}
if (stream->current) {
@@ -881,7 +877,6 @@ void stream_detach_behind(DisplayChannel *display, QRegion *region, Drawable *dr
{
Ring *ring = &display->priv->streams;
RingItem *item = ring_get_head(ring);
- GListIter iter;
DisplayChannelClient *dcc;
bool is_connected = red_channel_is_connected(RED_CHANNEL(display));
@@ -890,7 +885,7 @@ void stream_detach_behind(DisplayChannel *display, QRegion *region, Drawable *dr
int detach = 0;
item = ring_next(ring, item);
- FOREACH_DCC(display, iter, dcc) {
+ FOREACH_DCC(display, dcc) {
StreamAgent *agent = dcc_get_stream_agent(dcc, display_channel_get_stream_id(display, stream));
if (region_intersects(&agent->vis_region, region)) {
--
2.13.5
More information about the Spice-devel
mailing list