[Spice-devel] [PATCH spice-server v2] Use "base" as pipe item base field name
Christophe Fergeau
cfergeau at redhat.com
Mon Jun 18 12:16:42 UTC 2018
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
On Mon, Jun 18, 2018 at 11:29:38AM +0100, Frediano Ziglio wrote:
> Most of pipe items use this name for the base field.
> This also allows to use SPICE_UPCAST macros instead of a long
> SPICE_CONTAINEROF.
>
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
> server/dcc-send.c | 21 ++++++++-------------
> server/dcc.c | 29 ++++++++++++++---------------
> server/dcc.h | 4 ++--
> server/display-channel-private.h | 4 ++--
> server/display-channel.c | 4 ++--
> server/video-stream.c | 6 +++---
> server/video-stream.h | 2 +-
> 7 files changed, 32 insertions(+), 38 deletions(-)
>
> Changes since v1:
> - update more fields.
>
> diff --git a/server/dcc-send.c b/server/dcc-send.c
> index 211c69d7..79c3d48b 100644
> --- a/server/dcc-send.c
> +++ b/server/dcc-send.c
> @@ -638,7 +638,7 @@ static bool pipe_rendered_drawables_intersect_with_areas(DisplayChannelClient *d
>
> if (pipe_item->type != RED_PIPE_ITEM_TYPE_DRAW)
> continue;
> - drawable = SPICE_CONTAINEROF(pipe_item, RedDrawablePipeItem, dpi_pipe_item)->drawable;
> + drawable = SPICE_UPCAST(RedDrawablePipeItem, pipe_item)->drawable;
>
> if (ring_item_is_linked(&drawable->list_link))
> continue; // item hasn't been rendered
> @@ -731,7 +731,7 @@ static void red_pipe_replace_rendered_drawables_with_images(DisplayChannelClient
>
> if (pipe_item->type != RED_PIPE_ITEM_TYPE_DRAW)
> continue;
> - dpi = SPICE_CONTAINEROF(pipe_item, RedDrawablePipeItem, dpi_pipe_item);
> + dpi = SPICE_UPCAST(RedDrawablePipeItem, pipe_item);
> drawable = dpi->drawable;
> if (ring_item_is_linked(&drawable->list_link))
> continue; // item hasn't been rendered
> @@ -2392,7 +2392,7 @@ void dcc_send_item(RedChannelClient *rcc, RedPipeItem *pipe_item)
> reset_send_data(dcc);
> switch (pipe_item->type) {
> case RED_PIPE_ITEM_TYPE_DRAW: {
> - RedDrawablePipeItem *dpi = SPICE_CONTAINEROF(pipe_item, RedDrawablePipeItem, dpi_pipe_item);
> + RedDrawablePipeItem *dpi = SPICE_UPCAST(RedDrawablePipeItem, pipe_item);
> marshall_qxl_drawable(rcc, m, dpi);
> break;
> }
> @@ -2432,28 +2432,23 @@ void dcc_send_item(RedChannelClient *rcc, RedPipeItem *pipe_item)
> red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_INVAL_ALL_PALETTES);
> break;
> case RED_PIPE_ITEM_TYPE_CREATE_SURFACE: {
> - RedSurfaceCreateItem *surface_create = SPICE_CONTAINEROF(pipe_item, RedSurfaceCreateItem,
> - pipe_item);
> + RedSurfaceCreateItem *surface_create = SPICE_UPCAST(RedSurfaceCreateItem, pipe_item);
> marshall_surface_create(rcc, m, &surface_create->surface_create);
> break;
> }
> case RED_PIPE_ITEM_TYPE_DESTROY_SURFACE: {
> - RedSurfaceDestroyItem *surface_destroy = SPICE_CONTAINEROF(pipe_item, RedSurfaceDestroyItem,
> - pipe_item);
> + RedSurfaceDestroyItem *surface_destroy = SPICE_UPCAST(RedSurfaceDestroyItem, pipe_item);
> marshall_surface_destroy(rcc, m, surface_destroy->surface_destroy.surface_id);
> break;
> }
> case RED_PIPE_ITEM_TYPE_MONITORS_CONFIG: {
> - RedMonitorsConfigItem *monconf_item = SPICE_CONTAINEROF(pipe_item,
> - RedMonitorsConfigItem,
> - pipe_item);
> + RedMonitorsConfigItem *monconf_item = SPICE_UPCAST(RedMonitorsConfigItem, pipe_item);
> marshall_monitors_config(rcc, m, monconf_item->monitors_config);
> break;
> }
> case RED_PIPE_ITEM_TYPE_STREAM_ACTIVATE_REPORT: {
> - RedStreamActivateReportItem *report_item = SPICE_CONTAINEROF(pipe_item,
> - RedStreamActivateReportItem,
> - pipe_item);
> + RedStreamActivateReportItem *report_item =
> + SPICE_UPCAST(RedStreamActivateReportItem, pipe_item);
> marshall_stream_activate_report(rcc, m, report_item);
> break;
> }
> diff --git a/server/dcc.c b/server/dcc.c
> index 15b65978..d96f1b2b 100644
> --- a/server/dcc.c
> +++ b/server/dcc.c
> @@ -202,7 +202,7 @@ static RedSurfaceCreateItem *red_surface_create_item_new(RedChannel* channel,
> create->surface_create.flags = flags;
> create->surface_create.format = format;
>
> - red_pipe_item_init(&create->pipe_item, RED_PIPE_ITEM_TYPE_CREATE_SURFACE);
> + red_pipe_item_init(&create->base, RED_PIPE_ITEM_TYPE_CREATE_SURFACE);
> return create;
> }
>
> @@ -246,7 +246,7 @@ bool dcc_clear_surface_drawables_from_pipe(DisplayChannelClient *dcc, int surfac
>
> l = l->next;
> if (item->type == RED_PIPE_ITEM_TYPE_DRAW) {
> - dpi = SPICE_CONTAINEROF(item, RedDrawablePipeItem, dpi_pipe_item);
> + dpi = SPICE_UPCAST(RedDrawablePipeItem, item);
> drawable = dpi->drawable;
> } else if (item->type == RED_PIPE_ITEM_TYPE_UPGRADE) {
> drawable = SPICE_UPCAST(RedUpgradeItem, item)->drawable;
> @@ -313,7 +313,7 @@ void dcc_create_surface(DisplayChannelClient *dcc, int surface_id)
> surface->context.height,
> surface->context.format, flags);
> dcc->priv->surface_client_created[surface_id] = TRUE;
> - red_channel_client_pipe_add(RED_CHANNEL_CLIENT(dcc), &create->pipe_item);
> + red_channel_client_pipe_add(RED_CHANNEL_CLIENT(dcc), &create->base);
> }
>
> // adding the pipe item after pos. If pos == NULL, adding to head.
> @@ -433,8 +433,7 @@ static void add_drawable_surface_images(DisplayChannelClient *dcc, Drawable *dra
>
> static void red_drawable_pipe_item_free(RedPipeItem *item)
> {
> - RedDrawablePipeItem *dpi = SPICE_CONTAINEROF(item, RedDrawablePipeItem,
> - dpi_pipe_item);
> + RedDrawablePipeItem *dpi = SPICE_UPCAST(RedDrawablePipeItem, item);
> spice_assert(item->refcount == 0);
>
> dpi->drawable->pipes = g_list_remove(dpi->drawable->pipes, dpi);
> @@ -451,7 +450,7 @@ static RedDrawablePipeItem *red_drawable_pipe_item_new(DisplayChannelClient *dcc
> dpi->drawable = drawable;
> dpi->dcc = dcc;
> drawable->pipes = g_list_prepend(drawable->pipes, dpi);
> - red_pipe_item_init_full(&dpi->dpi_pipe_item, RED_PIPE_ITEM_TYPE_DRAW,
> + red_pipe_item_init_full(&dpi->base, RED_PIPE_ITEM_TYPE_DRAW,
> red_drawable_pipe_item_free);
> drawable->refs++;
> return dpi;
> @@ -462,7 +461,7 @@ void dcc_prepend_drawable(DisplayChannelClient *dcc, Drawable *drawable)
> RedDrawablePipeItem *dpi = red_drawable_pipe_item_new(dcc, drawable);
>
> add_drawable_surface_images(dcc, drawable);
> - red_channel_client_pipe_add(RED_CHANNEL_CLIENT(dcc), &dpi->dpi_pipe_item);
> + red_channel_client_pipe_add(RED_CHANNEL_CLIENT(dcc), &dpi->base);
> }
>
> void dcc_append_drawable(DisplayChannelClient *dcc, Drawable *drawable)
> @@ -470,7 +469,7 @@ void dcc_append_drawable(DisplayChannelClient *dcc, Drawable *drawable)
> RedDrawablePipeItem *dpi = red_drawable_pipe_item_new(dcc, drawable);
>
> add_drawable_surface_images(dcc, drawable);
> - red_channel_client_pipe_add_tail(RED_CHANNEL_CLIENT(dcc), &dpi->dpi_pipe_item);
> + red_channel_client_pipe_add_tail(RED_CHANNEL_CLIENT(dcc), &dpi->base);
> }
>
> void dcc_add_drawable_after(DisplayChannelClient *dcc, Drawable *drawable, RedPipeItem *pos)
> @@ -478,7 +477,7 @@ void dcc_add_drawable_after(DisplayChannelClient *dcc, Drawable *drawable, RedPi
> RedDrawablePipeItem *dpi = red_drawable_pipe_item_new(dcc, drawable);
>
> add_drawable_surface_images(dcc, drawable);
> - red_channel_client_pipe_add_after(RED_CHANNEL_CLIENT(dcc), &dpi->dpi_pipe_item, pos);
> + red_channel_client_pipe_add_after(RED_CHANNEL_CLIENT(dcc), &dpi->base, pos);
> }
>
> static void dcc_init_stream_agents(DisplayChannelClient *dcc)
> @@ -634,9 +633,9 @@ void dcc_video_stream_agent_clip(DisplayChannelClient* dcc, VideoStreamAgent *ag
> red_channel_client_pipe_add(RED_CHANNEL_CLIENT(dcc), &item->base);
> }
>
> -static void red_monitors_config_item_free(RedPipeItem *base)
> +static void red_monitors_config_item_free(RedPipeItem *pipe_item)
> {
> - RedMonitorsConfigItem *item = SPICE_CONTAINEROF(base, RedMonitorsConfigItem, pipe_item);
> + RedMonitorsConfigItem *item = SPICE_UPCAST(RedMonitorsConfigItem, pipe_item);
>
> monitors_config_unref(item->monitors_config);
> g_free(item);
> @@ -650,7 +649,7 @@ static RedMonitorsConfigItem *red_monitors_config_item_new(RedChannel* channel,
> mci = g_new(RedMonitorsConfigItem, 1);
> mci->monitors_config = monitors_config_ref(monitors_config);
>
> - red_pipe_item_init_full(&mci->pipe_item, RED_PIPE_ITEM_TYPE_MONITORS_CONFIG,
> + red_pipe_item_init_full(&mci->base, RED_PIPE_ITEM_TYPE_MONITORS_CONFIG,
> red_monitors_config_item_free);
> return mci;
> }
> @@ -673,7 +672,7 @@ void dcc_push_monitors_config(DisplayChannelClient *dcc)
>
> mci = red_monitors_config_item_new(red_channel_client_get_channel(RED_CHANNEL_CLIENT(dcc)),
> monitors_config);
> - red_channel_client_pipe_add(RED_CHANNEL_CLIENT(dcc), &mci->pipe_item);
> + red_channel_client_pipe_add(RED_CHANNEL_CLIENT(dcc), &mci->base);
> }
>
> static RedSurfaceDestroyItem *red_surface_destroy_item_new(uint32_t surface_id)
> @@ -682,7 +681,7 @@ static RedSurfaceDestroyItem *red_surface_destroy_item_new(uint32_t surface_id)
>
> destroy = g_new(RedSurfaceDestroyItem, 1);
> destroy->surface_destroy.surface_id = surface_id;
> - red_pipe_item_init(&destroy->pipe_item, RED_PIPE_ITEM_TYPE_DESTROY_SURFACE);
> + red_pipe_item_init(&destroy->base, RED_PIPE_ITEM_TYPE_DESTROY_SURFACE);
>
> return destroy;
> }
> @@ -744,7 +743,7 @@ void dcc_destroy_surface(DisplayChannelClient *dcc, uint32_t surface_id)
>
> dcc->priv->surface_client_created[surface_id] = FALSE;
> destroy = red_surface_destroy_item_new(surface_id);
> - red_channel_client_pipe_add(RED_CHANNEL_CLIENT(dcc), &destroy->pipe_item);
> + red_channel_client_pipe_add(RED_CHANNEL_CLIENT(dcc), &destroy->base);
> }
>
> #define MIN_DIMENSION_TO_QUIC 3
> diff --git a/server/dcc.h b/server/dcc.h
> index 16d60ed0..76c078bf 100644
> --- a/server/dcc.h
> +++ b/server/dcc.h
> @@ -96,7 +96,7 @@ typedef struct FreeList {
> #define DCC_TO_DC(dcc) ((DisplayChannel*)red_channel_client_get_channel((RedChannelClient*)dcc))
>
> typedef struct RedSurfaceCreateItem {
> - RedPipeItem pipe_item;
> + RedPipeItem base;
> SpiceMsgSurfaceCreate surface_create;
> } RedSurfaceCreateItem;
>
> @@ -124,7 +124,7 @@ typedef struct RedImageItem {
> } RedImageItem;
>
> typedef struct RedDrawablePipeItem {
> - RedPipeItem dpi_pipe_item;
> + RedPipeItem base;
> Drawable *drawable;
> DisplayChannelClient *dcc;
> } RedDrawablePipeItem;
> diff --git a/server/display-channel-private.h b/server/display-channel-private.h
> index 617ce30d..27f0a019 100644
> --- a/server/display-channel-private.h
> +++ b/server/display-channel-private.h
> @@ -132,7 +132,7 @@ struct DisplayChannelPrivate
> DisplayChannelClient, _data)
>
> typedef struct RedMonitorsConfigItem {
> - RedPipeItem pipe_item;
> + RedPipeItem base;
> MonitorsConfig *monitors_config;
> } RedMonitorsConfigItem;
>
> @@ -174,7 +174,7 @@ int display_channel_get_video_stream_id(DisplayChannel *display, VideoStream *st
> VideoStream *display_channel_get_nth_video_stream(DisplayChannel *display, gint i);
>
> typedef struct RedSurfaceDestroyItem {
> - RedPipeItem pipe_item;
> + RedPipeItem base;
> SpiceMsgSurfaceDestroy surface_destroy;
> } RedSurfaceDestroyItem;
>
> diff --git a/server/display-channel.c b/server/display-channel.c
> index b74c1e95..5f2e866f 100644
> --- a/server/display-channel.c
> +++ b/server/display-channel.c
> @@ -385,7 +385,7 @@ static void pipes_add_drawable_after(DisplayChannel *display,
> dpi_pos_after = l->data;
>
> num_other_linked++;
> - dcc_add_drawable_after(dpi_pos_after->dcc, drawable, &dpi_pos_after->dpi_pipe_item);
> + dcc_add_drawable_after(dpi_pos_after->dcc, drawable, &dpi_pos_after->base);
> }
>
> if (num_other_linked == 0) {
> @@ -446,7 +446,7 @@ static void drawable_remove_from_pipes(Drawable *drawable)
> RedChannelClient *rcc;
>
> rcc = RED_CHANNEL_CLIENT(dpi->dcc);
> - red_channel_client_pipe_remove_and_release(rcc, &dpi->dpi_pipe_item);
> + red_channel_client_pipe_remove_and_release(rcc, &dpi->base);
> }
> }
>
> diff --git a/server/video-stream.c b/server/video-stream.c
> index a4b83b4f..b624093e 100644
> --- a/server/video-stream.c
> +++ b/server/video-stream.c
> @@ -365,7 +365,7 @@ static void before_reattach_stream(DisplayChannel *display,
> agent = dcc_get_video_stream_agent(dcc, index);
>
> if (red_channel_client_pipe_item_is_linked(RED_CHANNEL_CLIENT(dcc),
> - &dpi->dpi_pipe_item)) {
> + &dpi->base)) {
> #ifdef STREAM_STATS
> agent->stats.num_drops_pipe++;
> #endif
> @@ -755,11 +755,11 @@ void dcc_create_stream(DisplayChannelClient *dcc, VideoStream *stream)
> RedStreamActivateReportItem *report_pipe_item = g_new0(RedStreamActivateReportItem, 1);
>
> agent->report_id = rand();
> - red_pipe_item_init(&report_pipe_item->pipe_item,
> + red_pipe_item_init(&report_pipe_item->base,
> RED_PIPE_ITEM_TYPE_STREAM_ACTIVATE_REPORT);
> report_pipe_item->stream_id = stream_id;
> report_pipe_item->report_id = agent->report_id;
> - red_channel_client_pipe_add(RED_CHANNEL_CLIENT(dcc), &report_pipe_item->pipe_item);
> + red_channel_client_pipe_add(RED_CHANNEL_CLIENT(dcc), &report_pipe_item->base);
> }
> #ifdef STREAM_STATS
> memset(&agent->stats, 0, sizeof(StreamStats));
> diff --git a/server/video-stream.h b/server/video-stream.h
> index b733771b..46b076fd 100644
> --- a/server/video-stream.h
> +++ b/server/video-stream.h
> @@ -54,7 +54,7 @@ typedef struct RedUpgradeItem {
> } RedUpgradeItem;
>
> typedef struct RedStreamActivateReportItem {
> - RedPipeItem pipe_item;
> + RedPipeItem base;
> uint32_t stream_id;
> uint32_t report_id;
> } RedStreamActivateReportItem;
> --
> 2.17.1
>
> _______________________________________________
> 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: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20180618/a2ced1ab/attachment.sig>
More information about the Spice-devel
mailing list