[PATCH spice-server 1/3] red-worker: Reuse code to process cursor command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Code to read and process cursor commands were the same
so use a common function for better reuse.

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 server/red-worker.c | 36 +++++++++++++++++-------------------
 1 file changed, 17 insertions(+), 19 deletions(-)

diff --git a/server/red-worker.c b/server/red-worker.c
index 9fd565f..1cd6250 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -104,6 +104,19 @@ void red_drawable_unref(RedDrawable *red_drawable)
     free(red_drawable);
 }
 
+static gboolean red_process_cursor_cmd(RedWorker *worker, const QXLCommandExt *ext)
+{
+    RedCursorCmd *cursor_cmd;
+
+    cursor_cmd = spice_new0(RedCursorCmd, 1);
+    if (red_get_cursor_cmd(&worker->mem_slots, ext->group_id, cursor_cmd, ext->cmd.data)) {
+        free(cursor_cmd);
+        return FALSE;
+    }
+    cursor_channel_process_cmd(worker->cursor_channel, cursor_cmd);
+    return TRUE;
+}
+
 static int red_process_cursor(RedWorker *worker, int *ring_is_empty)
 {
     QXLCommandExt ext_cmd;
@@ -134,18 +147,9 @@ static int red_process_cursor(RedWorker *worker, int *ring_is_empty)
 
         worker->cursor_poll_tries = 0;
         switch (ext_cmd.cmd.type) {
-        case QXL_CMD_CURSOR: {
-            RedCursorCmd *cursor = spice_new0(RedCursorCmd, 1);
-
-            if (red_get_cursor_cmd(&worker->mem_slots, ext_cmd.group_id,
-                                    cursor, ext_cmd.cmd.data)) {
-                free(cursor);
-                break;
-            }
-
-            cursor_channel_process_cmd(worker->cursor_channel, cursor);
+        case QXL_CMD_CURSOR:
+            red_process_cursor_cmd(worker, &ext_cmd);
             break;
-        }
         default:
             spice_warning("bad command type");
         }
@@ -980,18 +984,12 @@ static void handle_dev_close(void *opaque, void *payload)
 
 static int loadvm_command(RedWorker *worker, QXLCommandExt *ext)
 {
-    RedCursorCmd *cursor_cmd;
     RedSurfaceCmd *surface_cmd;
 
     switch (ext->cmd.type) {
     case QXL_CMD_CURSOR:
-        cursor_cmd = spice_new0(RedCursorCmd, 1);
-        if (red_get_cursor_cmd(&worker->mem_slots, ext->group_id, cursor_cmd, ext->cmd.data)) {
-            free(cursor_cmd);
-            return FALSE;
-        }
-        cursor_channel_process_cmd(worker->cursor_channel, cursor_cmd);
-        break;
+        return red_process_cursor_cmd(worker, ext);
+
     case QXL_CMD_SURFACE:
         surface_cmd = spice_new0(RedSurfaceCmd, 1);
         if (red_get_surface_cmd(&worker->mem_slots, ext->group_id, surface_cmd, ext->cmd.data)) {
-- 
2.9.3

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]