[Spice-commits] 2 commits - server/red-client.cpp server/reds.cpp server/reds-private.h

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 1 08:04:05 UTC 2021


 server/red-client.cpp |   15 +++++----------
 server/reds-private.h |    3 ---
 server/reds.cpp       |   22 +++++++++-------------
 3 files changed, 14 insertions(+), 26 deletions(-)

New commits:
commit 3f5ba6e5654e0ad75aa22d16382a18f18a39817d
Author: Rosen Penev <rosenp at gmail.com>
Date:   Sun May 9 02:48:51 2021 -0700

    red-client: Remove FOREACH_CHANNEL_CLIENT macro
    
    Since the conversion to a for range loop, there's no point to this
    macro.
    
    Signed-off-by: Rosen Penev <rosenp at gmail.com>
    Acked-by: Frediano Ziglio <freddy77 at gmail.com>

diff --git a/server/red-client.cpp b/server/red-client.cpp
index 9a722b81..248dbd50 100644
--- a/server/red-client.cpp
+++ b/server/red-client.cpp
@@ -21,9 +21,6 @@
 #include "red-client.h"
 #include "reds.h"
 
-#define FOREACH_CHANNEL_CLIENT(_client, _data) \
-    for (const auto &_data: _client->channels)
-
 RedClient::~RedClient()
 {
     spice_debug("release client=%p", this);
@@ -50,7 +47,7 @@ void RedClient::set_migration_seamless() // dest
     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(this, rcc) {
+    for (const auto &rcc : channels) {
         if (rcc->set_migration_seamless()) {
             num_migrated_channels++;
         }
@@ -67,7 +64,7 @@ void RedClient::migrate()
                       " this might be a BUG",
                       (void*) thread_id, (void*) pthread_self());
     }
-    FOREACH_CHANNEL_CLIENT(this, rcc) {
+    for (const auto &rcc : channels) {
         if (rcc->is_connected()) {
             auto channel = rcc->get_channel();
             channel->migrate_client(rcc.get());
@@ -128,10 +125,8 @@ void RedClient::destroy()
 /* client->lock should be locked */
 RedChannelClient *RedClient::get_channel(int type, int id)
 {
-    FOREACH_CHANNEL_CLIENT(this, rcc) {
-        RedChannel *channel;
-
-        channel = rcc->get_channel();
+    for (const auto &rcc : channels) {
+        auto channel = rcc->get_channel();
         if (channel->type() == type && channel->id() == id) {
             return rcc.get();
         }
@@ -199,7 +194,7 @@ void RedClient::semi_seamless_migrate_complete()
         return;
     }
     during_target_migrate = FALSE;
-    FOREACH_CHANNEL_CLIENT(this, rcc) {
+    for (const auto &rcc : channels) {
         rcc->semi_seamless_migration_complete();
     }
     pthread_mutex_unlock(&lock);
commit 4b56942bf5c1ca033832fb28eff1dc4500de151d
Author: Rosen Penev <rosenp at gmail.com>
Date:   Sun May 9 02:53:44 2021 -0700

    reds: Remove FOREACH_QXL_INSTANCE macro
    
    Since the conversion to a for range loop, there's no point to this
    macro.
    
    Signed-off-by: Rosen Penev <rosenp at gmail.com>
    Acked-by: Frediano Ziglio <freddy77 at gmail.com>

diff --git a/server/reds-private.h b/server/reds-private.h
index 31aa5d63..51534d94 100644
--- a/server/reds-private.h
+++ b/server/reds-private.h
@@ -139,7 +139,4 @@ struct RedsState {
     RedRecord *record;
 };
 
-#define FOREACH_QXL_INSTANCE(_reds, _qxl) \
-    for (auto _qxl: _reds->qxl_instances)
-
 #endif /* REDS_PRIVATE_H_ */
diff --git a/server/reds.cpp b/server/reds.cpp
index 3fd6553a..344affce 100644
--- a/server/reds.cpp
+++ b/server/reds.cpp
@@ -577,7 +577,7 @@ static void reds_set_mouse_mode(RedsState *reds, SpiceMouseMode mode)
     }
     reds->mouse_mode = mode;
 
-    FOREACH_QXL_INSTANCE(reds, qxl) {
+    for (const auto &qxl : reds->qxl_instances) {
         red_qxl_set_mouse_mode(qxl, mode);
     }
 
@@ -800,7 +800,7 @@ void reds_marshall_device_display_info(RedsState *reds, SpiceMarshaller *m)
     void *device_count_ptr = spice_marshaller_add_uint32(m, device_count);
 
     // add the qxl devices to the message
-    FOREACH_QXL_INSTANCE(reds, qxl) {
+    for (const auto &qxl : reds->qxl_instances) {
         device_count += red_qxl_marshall_device_display_info(qxl, m);
     }
 
@@ -4307,7 +4307,7 @@ void reds_update_client_mouse_allowed(RedsState *reds)
     if (num_active_workers > 0) {
 
         allow_now = TRUE;
-        FOREACH_QXL_INSTANCE(reds, qxl) {
+        for (const auto &qxl : reds->qxl_instances) {
             if (red_qxl_get_allow_client_mouse(qxl, &x_res, &y_res, &allow_now)) {
                 break;
             }
@@ -4340,7 +4340,7 @@ static gboolean reds_use_client_monitors_config(RedsState *reds)
 
 static void reds_client_monitors_config(RedsState *reds, VDAgentMonitorsConfig *monitors_config)
 {
-    FOREACH_QXL_INSTANCE(reds, qxl) {
+    for (const auto &qxl : reds->qxl_instances) {
         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");
@@ -4363,7 +4363,7 @@ void reds_on_ic_change(RedsState *reds)
 {
     int compression_level = calc_compression_level(reds);
 
-    FOREACH_QXL_INSTANCE(reds, qxl) {
+    for (const auto &qxl : reds->qxl_instances) {
         red_qxl_set_compression_level(qxl, compression_level);
         red_qxl_on_ic_change(qxl, spice_server_get_image_compression(reds));
     }
@@ -4373,7 +4373,7 @@ void reds_on_sv_change(RedsState *reds)
 {
     int compression_level = calc_compression_level(reds);
 
-    FOREACH_QXL_INSTANCE(reds, qxl) {
+    for (const auto &qxl : reds->qxl_instances) {
         red_qxl_set_compression_level(qxl, compression_level);
         red_qxl_on_sv_change(qxl, reds_get_streaming_video(reds));
     }
@@ -4381,23 +4381,19 @@ void reds_on_sv_change(RedsState *reds)
 
 void reds_on_vc_change(RedsState *reds)
 {
-    FOREACH_QXL_INSTANCE(reds, qxl) {
+    for (const auto &qxl : reds->qxl_instances) {
         red_qxl_on_vc_change(qxl, reds_get_video_codecs(reds));
     }
 }
 
 void reds_on_vm_stop(RedsState *reds)
 {
-    FOREACH_QXL_INSTANCE(reds, qxl) {
-        red_qxl_stop(qxl);
-    }
+    std::for_each(reds->qxl_instances.begin(), reds->qxl_instances.end(), red_qxl_stop);
 }
 
 void reds_on_vm_start(RedsState *reds)
 {
-    FOREACH_QXL_INSTANCE(reds, qxl) {
-        red_qxl_start(qxl);
-    }
+    std::for_each(reds->qxl_instances.begin(), reds->qxl_instances.end(), red_qxl_start);
 }
 
 uint32_t reds_qxl_ram_size(RedsState *reds)


More information about the Spice-commits mailing list