mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-01-06 21:03:27 +00:00
Base FOREACH_CLIENT on GLIST_FOREACH
Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
This commit is contained in:
parent
3fa2f12c1f
commit
9b5f93d1a7
@ -44,10 +44,10 @@ static void main_channel_client_on_disconnect(RedChannelClient *rcc)
|
||||
|
||||
RedClient *main_channel_get_client_by_link_id(MainChannel *main_chan, uint32_t connection_id)
|
||||
{
|
||||
GList *link, *next;
|
||||
GListIter iter;
|
||||
RedChannelClient *rcc;
|
||||
|
||||
FOREACH_CLIENT(main_chan, link, next, rcc) {
|
||||
FOREACH_CLIENT(main_chan, iter, rcc) {
|
||||
MainChannelClient *mcc = MAIN_CHANNEL_CLIENT(rcc);
|
||||
if (main_channel_client_get_connection_id(mcc) == connection_id) {
|
||||
return red_channel_client_get_client(rcc);
|
||||
@ -334,10 +334,10 @@ MainChannel* main_channel_new(RedsState *reds)
|
||||
|
||||
static int main_channel_connect_semi_seamless(MainChannel *main_channel)
|
||||
{
|
||||
GList *link, *next;
|
||||
GListIter iter;
|
||||
RedChannelClient *rcc;
|
||||
|
||||
FOREACH_CLIENT(main_channel, link, next, rcc) {
|
||||
FOREACH_CLIENT(main_channel, iter, rcc) {
|
||||
MainChannelClient *mcc = MAIN_CHANNEL_CLIENT(rcc);
|
||||
if (main_channel_client_connect_semi_seamless(mcc))
|
||||
main_channel->num_clients_mig_wait++;
|
||||
@ -347,12 +347,12 @@ static int main_channel_connect_semi_seamless(MainChannel *main_channel)
|
||||
|
||||
static int main_channel_connect_seamless(MainChannel *main_channel)
|
||||
{
|
||||
GList *link, *next;
|
||||
GListIter iter;
|
||||
RedChannelClient *rcc;
|
||||
|
||||
spice_assert(g_list_length(main_channel->base.clients) == 1);
|
||||
|
||||
FOREACH_CLIENT(main_channel, link, next, rcc) {
|
||||
FOREACH_CLIENT(main_channel, iter, rcc) {
|
||||
MainChannelClient *mcc = MAIN_CHANNEL_CLIENT(rcc);
|
||||
main_channel_client_connect_seamless(mcc);
|
||||
main_channel->num_clients_mig_wait++;
|
||||
@ -389,10 +389,10 @@ int main_channel_migrate_connect(MainChannel *main_channel, RedsMigSpice *mig_ta
|
||||
|
||||
void main_channel_migrate_cancel_wait(MainChannel *main_chan)
|
||||
{
|
||||
GList *link, *next;
|
||||
GListIter iter;
|
||||
RedChannelClient *rcc;
|
||||
|
||||
FOREACH_CLIENT(main_chan, link, next, rcc) {
|
||||
FOREACH_CLIENT(main_chan, iter, rcc) {
|
||||
MainChannelClient *mcc = MAIN_CHANNEL_CLIENT(rcc);
|
||||
main_channel_client_migrate_cancel_wait(mcc);
|
||||
}
|
||||
@ -401,7 +401,7 @@ void main_channel_migrate_cancel_wait(MainChannel *main_chan)
|
||||
|
||||
int main_channel_migrate_src_complete(MainChannel *main_chan, int success)
|
||||
{
|
||||
GList *link, *next;
|
||||
GListIter iter;
|
||||
int semi_seamless_count = 0;
|
||||
RedChannelClient *rcc;
|
||||
|
||||
@ -412,7 +412,7 @@ int main_channel_migrate_src_complete(MainChannel *main_chan, int success)
|
||||
return 0;
|
||||
}
|
||||
|
||||
FOREACH_CLIENT(main_chan, link, next, rcc) {
|
||||
FOREACH_CLIENT(main_chan, iter, rcc) {
|
||||
MainChannelClient *mcc = MAIN_CHANNEL_CLIENT(rcc);
|
||||
if (main_channel_client_migrate_src_complete(mcc, success))
|
||||
semi_seamless_count++;
|
||||
|
||||
@ -87,10 +87,10 @@ void red_channel_add_client(RedChannel *channel, RedChannelClient *rcc)
|
||||
|
||||
int red_channel_test_remote_common_cap(RedChannel *channel, uint32_t cap)
|
||||
{
|
||||
GList *link, *next;
|
||||
GListIter iter;
|
||||
RedChannelClient *rcc;
|
||||
|
||||
FOREACH_CLIENT(channel, link, next, rcc) {
|
||||
FOREACH_CLIENT(channel, iter, rcc) {
|
||||
if (!red_channel_client_test_remote_common_cap(rcc, cap)) {
|
||||
return FALSE;
|
||||
}
|
||||
@ -100,10 +100,10 @@ int red_channel_test_remote_common_cap(RedChannel *channel, uint32_t cap)
|
||||
|
||||
int red_channel_test_remote_cap(RedChannel *channel, uint32_t cap)
|
||||
{
|
||||
GList *link, *next;
|
||||
GListIter iter;
|
||||
RedChannelClient *rcc;
|
||||
|
||||
FOREACH_CLIENT(channel, link, next, rcc) {
|
||||
FOREACH_CLIENT(channel, iter, rcc) {
|
||||
if (!red_channel_client_test_remote_cap(rcc, cap)) {
|
||||
return FALSE;
|
||||
}
|
||||
@ -486,13 +486,13 @@ void red_channel_apply_clients_data(RedChannel *channel, channel_client_callback
|
||||
|
||||
int red_channel_all_blocked(RedChannel *channel)
|
||||
{
|
||||
GList *link, *next;
|
||||
GListIter iter;
|
||||
RedChannelClient *rcc;
|
||||
|
||||
if (!channel || !channel->clients) {
|
||||
return FALSE;
|
||||
}
|
||||
FOREACH_CLIENT(channel, link, next, rcc) {
|
||||
FOREACH_CLIENT(channel, iter, rcc) {
|
||||
if (!red_channel_client_is_blocked(rcc)) {
|
||||
return FALSE;
|
||||
}
|
||||
@ -502,10 +502,10 @@ int red_channel_all_blocked(RedChannel *channel)
|
||||
|
||||
int red_channel_any_blocked(RedChannel *channel)
|
||||
{
|
||||
GList *link, *next;
|
||||
GListIter iter;
|
||||
RedChannelClient *rcc;
|
||||
|
||||
FOREACH_CLIENT(channel, link, next, rcc) {
|
||||
FOREACH_CLIENT(channel, iter, rcc) {
|
||||
if (red_channel_client_is_blocked(rcc)) {
|
||||
return TRUE;
|
||||
}
|
||||
@ -529,10 +529,10 @@ int red_channel_get_first_socket(RedChannel *channel)
|
||||
|
||||
int red_channel_no_item_being_sent(RedChannel *channel)
|
||||
{
|
||||
GList *link, *next;
|
||||
GListIter iter;
|
||||
RedChannelClient *rcc;
|
||||
|
||||
FOREACH_CLIENT(channel, link, next, rcc) {
|
||||
FOREACH_CLIENT(channel, iter, rcc) {
|
||||
if (!red_channel_client_no_item_being_sent(rcc)) {
|
||||
return FALSE;
|
||||
}
|
||||
@ -740,7 +740,7 @@ static int red_channel_pipes_create_batch(RedChannel *channel,
|
||||
new_pipe_item_t creator, void *data,
|
||||
rcc_item_t pipe_add)
|
||||
{
|
||||
GList *link, *next;
|
||||
GListIter iter;
|
||||
RedChannelClient *rcc;
|
||||
RedPipeItem *item;
|
||||
int num = 0, n = 0;
|
||||
@ -748,7 +748,7 @@ static int red_channel_pipes_create_batch(RedChannel *channel,
|
||||
spice_assert(creator != NULL);
|
||||
spice_assert(pipe_add != NULL);
|
||||
|
||||
FOREACH_CLIENT(channel, link, next, rcc) {
|
||||
FOREACH_CLIENT(channel, iter, rcc) {
|
||||
item = (*creator)(rcc, data, num++);
|
||||
if (item) {
|
||||
(*pipe_add)(rcc, item);
|
||||
@ -783,11 +783,11 @@ void red_channel_pipes_new_add_tail(RedChannel *channel, new_pipe_item_t creator
|
||||
|
||||
uint32_t red_channel_max_pipe_size(RedChannel *channel)
|
||||
{
|
||||
GList *link, *next;
|
||||
GListIter iter;
|
||||
RedChannelClient *rcc;
|
||||
uint32_t pipe_size = 0;
|
||||
|
||||
FOREACH_CLIENT(channel, link, next, rcc) {
|
||||
FOREACH_CLIENT(channel, iter, rcc) {
|
||||
uint32_t new_size;
|
||||
new_size = red_channel_client_get_pipe_size(rcc);
|
||||
pipe_size = MAX(pipe_size, new_size);
|
||||
@ -797,11 +797,11 @@ uint32_t red_channel_max_pipe_size(RedChannel *channel)
|
||||
|
||||
uint32_t red_channel_min_pipe_size(RedChannel *channel)
|
||||
{
|
||||
GList *link, *next;
|
||||
GListIter iter;
|
||||
RedChannelClient *rcc;
|
||||
uint32_t pipe_size = ~0;
|
||||
|
||||
FOREACH_CLIENT(channel, link, next, rcc) {
|
||||
FOREACH_CLIENT(channel, iter, rcc) {
|
||||
uint32_t new_size;
|
||||
new_size = red_channel_client_get_pipe_size(rcc);
|
||||
pipe_size = MIN(pipe_size, new_size);
|
||||
@ -811,11 +811,11 @@ uint32_t red_channel_min_pipe_size(RedChannel *channel)
|
||||
|
||||
uint32_t red_channel_sum_pipes_size(RedChannel *channel)
|
||||
{
|
||||
GList *link, *next;
|
||||
GListIter iter;
|
||||
RedChannelClient *rcc;
|
||||
uint32_t sum = 0;
|
||||
|
||||
FOREACH_CLIENT(channel, link, next, rcc) {
|
||||
FOREACH_CLIENT(channel, iter, rcc) {
|
||||
sum += red_channel_client_get_pipe_size(rcc);
|
||||
}
|
||||
return sum;
|
||||
|
||||
@ -250,15 +250,9 @@ struct RedChannel {
|
||||
#endif
|
||||
};
|
||||
|
||||
#define FOREACH_CLIENT(channel, _link, _next, _data) \
|
||||
for (_link = (channel ? RED_CHANNEL(channel)->clients : NULL), \
|
||||
_next = (_link ? _link->next : NULL), \
|
||||
_data = (_link ? _link->data : NULL); \
|
||||
_link; \
|
||||
_link = _next, \
|
||||
_next = (_link ? _link->next : NULL), \
|
||||
_data = (_link ? _link->data : NULL))
|
||||
|
||||
#define FOREACH_CLIENT(_channel, _iter, _data) \
|
||||
GLIST_FOREACH((_channel ? RED_CHANNEL(_channel)->clients : NULL), \
|
||||
_iter, RedChannelClient, _data)
|
||||
|
||||
#define RED_CHANNEL(Channel) ((RedChannel *)(Channel))
|
||||
|
||||
|
||||
@ -481,7 +481,7 @@ static void guest_set_client_capabilities(RedWorker *worker)
|
||||
{
|
||||
int i;
|
||||
RedChannelClient *rcc;
|
||||
GList *link, *next;
|
||||
GListIter iter;
|
||||
uint8_t caps[SPICE_CAPABILITIES_SIZE] = { 0 };
|
||||
int caps_available[] = {
|
||||
SPICE_DISPLAY_CAP_SIZED_STREAM,
|
||||
@ -514,7 +514,7 @@ static void guest_set_client_capabilities(RedWorker *worker)
|
||||
for (i = 0 ; i < sizeof(caps_available) / sizeof(caps_available[0]); ++i) {
|
||||
SET_CAP(caps, caps_available[i]);
|
||||
}
|
||||
FOREACH_CLIENT(worker->display_channel, link, next, rcc) {
|
||||
FOREACH_CLIENT(worker->display_channel, iter, rcc) {
|
||||
for (i = 0 ; i < sizeof(caps_available) / sizeof(caps_available[0]); ++i) {
|
||||
if (!red_channel_client_test_remote_cap(rcc, caps_available[i]))
|
||||
CLEAR_CAP(caps, caps_available[i]);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user