[Spice-devel] [PATCH spice-server 1/3] red-worker: Reuse code to process cursor command
Christophe Fergeau
cfergeau at redhat.com
Fri Jan 20 09:49:03 UTC 2017
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
On Tue, Jan 10, 2017 at 03:59:36PM +0000, Frediano Ziglio wrote:
> Code to read and process cursor commands were the same
> so use a common function for better reuse.
>
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
> 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 at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20170120/626d584a/attachment-0001.sig>
More information about the Spice-devel
mailing list