[Spice-devel] [PATCH spice-server v6 03/19] windows: Do not use conflicting preprocessor macros

Frediano Ziglio fziglio at redhat.com
Tue Apr 30 12:24:03 UTC 2019


"interface" and "MAX_MONITORS" are defined in some Windows system
headers causing garbage code to be fed to the compiler.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/red-qxl.c | 52 ++++++++++++++++++------------------
 server/reds.c    | 68 ++++++++++++++++++++++++------------------------
 2 files changed, 60 insertions(+), 60 deletions(-)

diff --git a/server/red-qxl.c b/server/red-qxl.c
index 5fa974fc..d40d3970 100644
--- a/server/red-qxl.c
+++ b/server/red-qxl.c
@@ -966,95 +966,95 @@ RedsState* red_qxl_get_server(QXLState *qxl_state)
 
 void red_qxl_attach_worker(QXLInstance *qxl)
 {
-    QXLInterface *interface = qxl_get_interface(qxl);
-    interface->attache_worker(qxl, &qxl->st->qxl_worker);
+    QXLInterface *qxl_interface = qxl_get_interface(qxl);
+    qxl_interface->attache_worker(qxl, &qxl->st->qxl_worker);
 }
 
 void red_qxl_set_compression_level(QXLInstance *qxl, int level)
 {
-    QXLInterface *interface = qxl_get_interface(qxl);
-    interface->set_compression_level(qxl, level);
+    QXLInterface *qxl_interface = qxl_get_interface(qxl);
+    qxl_interface->set_compression_level(qxl, level);
 }
 
 void red_qxl_get_init_info(QXLInstance *qxl, QXLDevInitInfo *info)
 {
-    QXLInterface *interface = qxl_get_interface(qxl);
+    QXLInterface *qxl_interface = qxl_get_interface(qxl);
 
-    interface->get_init_info(qxl, info);
+    qxl_interface->get_init_info(qxl, info);
 }
 
 int red_qxl_get_command(QXLInstance *qxl, struct QXLCommandExt *cmd)
 {
-    QXLInterface *interface = qxl_get_interface(qxl);
+    QXLInterface *qxl_interface = qxl_get_interface(qxl);
 
-    return interface->get_command(qxl, cmd);
+    return qxl_interface->get_command(qxl, cmd);
 }
 
 int red_qxl_req_cmd_notification(QXLInstance *qxl)
 {
-    QXLInterface *interface = qxl_get_interface(qxl);
+    QXLInterface *qxl_interface = qxl_get_interface(qxl);
 
-    return interface->req_cmd_notification(qxl);
+    return qxl_interface->req_cmd_notification(qxl);
 }
 
 void red_qxl_release_resource(QXLInstance *qxl, struct QXLReleaseInfoExt release_info)
 {
-    QXLInterface *interface = qxl_get_interface(qxl);
+    QXLInterface *qxl_interface = qxl_get_interface(qxl);
 
-    interface->release_resource(qxl, release_info);
+    qxl_interface->release_resource(qxl, release_info);
 }
 
 int red_qxl_get_cursor_command(QXLInstance *qxl, struct QXLCommandExt *cmd)
 {
-    QXLInterface *interface = qxl_get_interface(qxl);
+    QXLInterface *qxl_interface = qxl_get_interface(qxl);
 
-    return interface->get_cursor_command(qxl, cmd);
+    return qxl_interface->get_cursor_command(qxl, cmd);
 }
 
 int red_qxl_req_cursor_notification(QXLInstance *qxl)
 {
-    QXLInterface *interface = qxl_get_interface(qxl);
+    QXLInterface *qxl_interface = qxl_get_interface(qxl);
 
-    return interface->req_cursor_notification(qxl);
+    return qxl_interface->req_cursor_notification(qxl);
 }
 
 void red_qxl_notify_update(QXLInstance *qxl, uint32_t update_id)
 {
-    QXLInterface *interface = qxl_get_interface(qxl);
+    QXLInterface *qxl_interface = qxl_get_interface(qxl);
 
-    interface->notify_update(qxl, update_id);
+    qxl_interface->notify_update(qxl, update_id);
 }
 
 int red_qxl_flush_resources(QXLInstance *qxl)
 {
-    QXLInterface *interface = qxl_get_interface(qxl);
+    QXLInterface *qxl_interface = qxl_get_interface(qxl);
 
-    return interface->flush_resources(qxl);
+    return qxl_interface->flush_resources(qxl);
 }
 
 void red_qxl_update_area_complete(QXLInstance *qxl, uint32_t surface_id,
                                   struct QXLRect *updated_rects,
                                   uint32_t num_updated_rects)
 {
-    QXLInterface *interface = qxl_get_interface(qxl);
+    QXLInterface *qxl_interface = qxl_get_interface(qxl);
 
-    interface->update_area_complete(qxl, surface_id, updated_rects, num_updated_rects);
+    qxl_interface->update_area_complete(qxl, surface_id, updated_rects, num_updated_rects);
 }
 
 void red_qxl_set_client_capabilities(QXLInstance *qxl,
                                      uint8_t client_present,
                                      uint8_t caps[SPICE_CAPABILITIES_SIZE])
 {
-    QXLInterface *interface = qxl_get_interface(qxl);
+    QXLInterface *qxl_interface = qxl_get_interface(qxl);
 
     if (qxl->st->running) {
-        interface->set_client_capabilities(qxl, client_present, caps);
+        qxl_interface->set_client_capabilities(qxl, client_present, caps);
     }
 }
 
 void red_qxl_async_complete(QXLInstance *qxl, uint64_t cookie)
 {
-    QXLInterface *interface = qxl_get_interface(qxl);
+    QXLInterface *qxl_interface = qxl_get_interface(qxl);
 
-    interface->async_complete(qxl, cookie);
+    qxl_interface->async_complete(qxl, cookie);
 }
diff --git a/server/reds.c b/server/reds.c
index 4e990351..3f1a4a05 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -1260,9 +1260,9 @@ void reds_release_agent_data_buffer(RedsState *reds, uint8_t *buf)
 static void reds_on_main_agent_monitors_config(RedsState *reds,
         MainChannelClient *mcc, const void *message, size_t size)
 {
-    const unsigned int MAX_MONITORS = 256;
+    const unsigned int MAX_NUM_MONITORS = 256;
     const unsigned int MAX_MONITOR_CONFIG_SIZE =
-       sizeof(VDAgentMonitorsConfig) + MAX_MONITORS * sizeof(VDAgentMonConfig);
+       sizeof(VDAgentMonitorsConfig) + MAX_NUM_MONITORS * sizeof(VDAgentMonConfig);
 
     VDAgentMessage *msg_header;
     VDAgentMonitorsConfig *monitors_config;
@@ -3385,12 +3385,12 @@ static int spice_server_char_device_remove_interface(RedsState *reds, SpiceBaseI
 SPICE_GNUC_VISIBLE int spice_server_add_interface(SpiceServer *reds,
                                                   SpiceBaseInstance *sin)
 {
-    const SpiceBaseInterface *interface = sin->sif;
+    const SpiceBaseInterface *base_interface = sin->sif;
 
-    if (strcmp(interface->type, SPICE_INTERFACE_KEYBOARD) == 0) {
+    if (strcmp(base_interface->type, SPICE_INTERFACE_KEYBOARD) == 0) {
         spice_debug("SPICE_INTERFACE_KEYBOARD");
-        if (interface->major_version != SPICE_INTERFACE_KEYBOARD_MAJOR ||
-            interface->minor_version > SPICE_INTERFACE_KEYBOARD_MINOR) {
+        if (base_interface->major_version != SPICE_INTERFACE_KEYBOARD_MAJOR ||
+            base_interface->minor_version > SPICE_INTERFACE_KEYBOARD_MINOR) {
             spice_warning("unsupported keyboard interface");
             return -1;
         }
@@ -3398,10 +3398,10 @@ SPICE_GNUC_VISIBLE int spice_server_add_interface(SpiceServer *reds,
                                         SPICE_UPCAST(SpiceKbdInstance, sin)) != 0) {
             return -1;
         }
-    } else if (strcmp(interface->type, SPICE_INTERFACE_MOUSE) == 0) {
+    } else if (strcmp(base_interface->type, SPICE_INTERFACE_MOUSE) == 0) {
         spice_debug("SPICE_INTERFACE_MOUSE");
-        if (interface->major_version != SPICE_INTERFACE_MOUSE_MAJOR ||
-            interface->minor_version > SPICE_INTERFACE_MOUSE_MINOR) {
+        if (base_interface->major_version != SPICE_INTERFACE_MOUSE_MAJOR ||
+            base_interface->minor_version > SPICE_INTERFACE_MOUSE_MINOR) {
             spice_warning("unsupported mouse interface");
             return -1;
         }
@@ -3409,12 +3409,12 @@ SPICE_GNUC_VISIBLE int spice_server_add_interface(SpiceServer *reds,
                                      SPICE_UPCAST(SpiceMouseInstance, sin)) != 0) {
             return -1;
         }
-    } else if (strcmp(interface->type, SPICE_INTERFACE_QXL) == 0) {
+    } else if (strcmp(base_interface->type, SPICE_INTERFACE_QXL) == 0) {
         QXLInstance *qxl;
 
         spice_debug("SPICE_INTERFACE_QXL");
-        if (interface->major_version != SPICE_INTERFACE_QXL_MAJOR ||
-            interface->minor_version > SPICE_INTERFACE_QXL_MINOR) {
+        if (base_interface->major_version != SPICE_INTERFACE_QXL_MAJOR ||
+            base_interface->minor_version > SPICE_INTERFACE_QXL_MINOR) {
             spice_warning("unsupported qxl interface");
             return -1;
         }
@@ -3438,11 +3438,11 @@ SPICE_GNUC_VISIBLE int spice_server_add_interface(SpiceServer *reds,
          * be called. */
         red_qxl_attach_worker(qxl);
         red_qxl_set_compression_level(qxl, calc_compression_level(reds));
-    } else if (strcmp(interface->type, SPICE_INTERFACE_TABLET) == 0) {
+    } else if (strcmp(base_interface->type, SPICE_INTERFACE_TABLET) == 0) {
         SpiceTabletInstance *tablet = SPICE_UPCAST(SpiceTabletInstance, sin);
         spice_debug("SPICE_INTERFACE_TABLET");
-        if (interface->major_version != SPICE_INTERFACE_TABLET_MAJOR ||
-            interface->minor_version > SPICE_INTERFACE_TABLET_MINOR) {
+        if (base_interface->major_version != SPICE_INTERFACE_TABLET_MAJOR ||
+            base_interface->minor_version > SPICE_INTERFACE_TABLET_MINOR) {
             spice_warning("unsupported tablet interface");
             return -1;
         }
@@ -3454,41 +3454,41 @@ SPICE_GNUC_VISIBLE int spice_server_add_interface(SpiceServer *reds,
             inputs_channel_set_tablet_logical_size(reds->inputs_channel, reds->monitor_mode.x_res, reds->monitor_mode.y_res);
         }
 
-    } else if (strcmp(interface->type, SPICE_INTERFACE_PLAYBACK) == 0) {
+    } else if (strcmp(base_interface->type, SPICE_INTERFACE_PLAYBACK) == 0) {
         spice_debug("SPICE_INTERFACE_PLAYBACK");
-        if (interface->major_version != SPICE_INTERFACE_PLAYBACK_MAJOR ||
-            interface->minor_version > SPICE_INTERFACE_PLAYBACK_MINOR) {
+        if (base_interface->major_version != SPICE_INTERFACE_PLAYBACK_MAJOR ||
+            base_interface->minor_version > SPICE_INTERFACE_PLAYBACK_MINOR) {
             spice_warning("unsupported playback interface");
             return -1;
         }
         snd_attach_playback(reds, SPICE_UPCAST(SpicePlaybackInstance, sin));
 
-    } else if (strcmp(interface->type, SPICE_INTERFACE_RECORD) == 0) {
+    } else if (strcmp(base_interface->type, SPICE_INTERFACE_RECORD) == 0) {
         spice_debug("SPICE_INTERFACE_RECORD");
-        if (interface->major_version != SPICE_INTERFACE_RECORD_MAJOR ||
-            interface->minor_version > SPICE_INTERFACE_RECORD_MINOR) {
+        if (base_interface->major_version != SPICE_INTERFACE_RECORD_MAJOR ||
+            base_interface->minor_version > SPICE_INTERFACE_RECORD_MINOR) {
             spice_warning("unsupported record interface");
             return -1;
         }
         snd_attach_record(reds, SPICE_UPCAST(SpiceRecordInstance, sin));
 
-    } else if (strcmp(interface->type, SPICE_INTERFACE_CHAR_DEVICE) == 0) {
-        if (interface->major_version != SPICE_INTERFACE_CHAR_DEVICE_MAJOR ||
-            interface->minor_version > SPICE_INTERFACE_CHAR_DEVICE_MINOR) {
+    } else if (strcmp(base_interface->type, SPICE_INTERFACE_CHAR_DEVICE) == 0) {
+        if (base_interface->major_version != SPICE_INTERFACE_CHAR_DEVICE_MAJOR ||
+            base_interface->minor_version > SPICE_INTERFACE_CHAR_DEVICE_MINOR) {
             spice_warning("unsupported char device interface");
             return -1;
         }
         spice_server_char_device_add_interface(reds, sin);
 
-    } else if (strcmp(interface->type, SPICE_INTERFACE_MIGRATION) == 0) {
+    } else if (strcmp(base_interface->type, SPICE_INTERFACE_MIGRATION) == 0) {
         spice_debug("SPICE_INTERFACE_MIGRATION");
         if (reds->migration_interface) {
             spice_warning("already have migration");
             return -1;
         }
 
-        if (interface->major_version != SPICE_INTERFACE_MIGRATION_MAJOR ||
-            interface->minor_version > SPICE_INTERFACE_MIGRATION_MINOR) {
+        if (base_interface->major_version != SPICE_INTERFACE_MIGRATION_MAJOR ||
+            base_interface->minor_version > SPICE_INTERFACE_MIGRATION_MINOR) {
             spice_warning("unsupported migration interface");
             return -1;
         }
@@ -3502,30 +3502,30 @@ SPICE_GNUC_VISIBLE int spice_server_add_interface(SpiceServer *reds,
 SPICE_GNUC_VISIBLE int spice_server_remove_interface(SpiceBaseInstance *sin)
 {
     RedsState *reds;
-    const SpiceBaseInterface *interface;
+    const SpiceBaseInterface *base_interface;
 
     g_return_val_if_fail(sin != NULL, -1);
 
-    interface = sin->sif;
-    if (strcmp(interface->type, SPICE_INTERFACE_TABLET) == 0) {
+    base_interface = sin->sif;
+    if (strcmp(base_interface->type, SPICE_INTERFACE_TABLET) == 0) {
         SpiceTabletInstance *tablet = SPICE_UPCAST(SpiceTabletInstance, sin);
         g_return_val_if_fail(tablet->st != NULL, -1);
         reds = spice_tablet_state_get_server(tablet->st);
         spice_debug("remove SPICE_INTERFACE_TABLET");
         inputs_channel_detach_tablet(reds->inputs_channel, tablet);
         reds_update_mouse_mode(reds);
-    } else if (strcmp(interface->type, SPICE_INTERFACE_PLAYBACK) == 0) {
+    } else if (strcmp(base_interface->type, SPICE_INTERFACE_PLAYBACK) == 0) {
         spice_debug("remove SPICE_INTERFACE_PLAYBACK");
         snd_detach_playback(SPICE_UPCAST(SpicePlaybackInstance, sin));
-    } else if (strcmp(interface->type, SPICE_INTERFACE_RECORD) == 0) {
+    } else if (strcmp(base_interface->type, SPICE_INTERFACE_RECORD) == 0) {
         spice_debug("remove SPICE_INTERFACE_RECORD");
         snd_detach_record(SPICE_UPCAST(SpiceRecordInstance, sin));
-    } else if (strcmp(interface->type, SPICE_INTERFACE_CHAR_DEVICE) == 0) {
+    } else if (strcmp(base_interface->type, SPICE_INTERFACE_CHAR_DEVICE) == 0) {
         SpiceCharDeviceInstance *char_device = SPICE_UPCAST(SpiceCharDeviceInstance, sin);
         g_return_val_if_fail(char_device->st != NULL, -1);
         reds = red_char_device_get_server(char_device->st);
         return spice_server_char_device_remove_interface(reds, sin);
-    } else if (strcmp(interface->type, SPICE_INTERFACE_QXL) == 0) {
+    } else if (strcmp(base_interface->type, SPICE_INTERFACE_QXL) == 0) {
         QXLInstance *qxl;
 
         qxl = SPICE_UPCAST(QXLInstance, sin);
-- 
2.20.1



More information about the Spice-devel mailing list