Re: [PATCH spice-gtk] Revert "Avoid clang warnings on casts with stricter alignment requirements"

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

 



Hi,

On Wed, Jun 28, 2017 at 01:48:12PM +0200, Victor Toso wrote:
> From: Victor Toso <me@xxxxxxxxxxxxxx>
>
> This reverts all spice-gtk changes from commit babe5630d5d3242b1d18
> while keeping the spice-common updates.

Sorry, I should have put more info here.

Something is off with this changes and they need more testing, so far
Pavel and I spotted:
- Two displays are always being opened in multi (two) heads;
- The SPICE_DISPLAY_CAP_PREF_VIDEO_CODEC_TYPE is being correctly set in
  Spice server but spice-gtk does not receive it.

I can add this info to the commit log before pushing.

Cheers,

>
> Signed-off-by: Victor Toso <victortoso@xxxxxxxxxx>
> ---
>  configure.ac                |  8 --------
>  src/channel-cursor.c        |  8 +++-----
>  src/channel-display-mjpeg.c |  2 +-
>  src/channel-main.c          |  2 +-
>  src/continuation.h          |  6 ++----
>  src/decode-glz-tmpl.c       |  2 +-
>  src/spice-channel.c         | 25 ++++++++++---------------
>  7 files changed, 18 insertions(+), 35 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index caa289a..62acafc 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -565,14 +565,6 @@ else
>    SPICE_WARNING([No D-Bus support, desktop integration and USB redirection may not work properly])
>  fi
>  
> -AC_ARG_ENABLE([alignment-checks],
> -  AS_HELP_STRING([--enable-alignment-checks],
> -                 [Enable runtime checks for cast alignment @<:@default=no@:>@]),
> -  [],
> -  enable_alignment_checks="no")
> -AS_IF([test "x$enable_alignment_checks" = "xyes"],
> -      [AC_DEFINE([SPICE_DEBUG_ALIGNMENT], 1, [Enable runtime checks for cast alignment])])
> -
>  SPICE_CHECK_LZ4
>  
>  dnl ===========================================================================
> diff --git a/src/channel-cursor.c b/src/channel-cursor.c
> index 14053a9..558c920 100644
> --- a/src/channel-cursor.c
> +++ b/src/channel-cursor.c
> @@ -381,11 +381,10 @@ static display_cursor *set_cursor(SpiceChannel *channel, SpiceCursor *scursor)
>      SpiceCursorHeader *hdr = &scursor->header;
>      display_cursor *cursor;
>      size_t size;
> -    guint32 i, pix_mask, pix;
> +    gint i, pix_mask, pix;
>      const guint8* data;
>      guint8 *rgba;
>      guint8 val;
> -    guint32 palette[16];
>  
>      CHANNEL_DEBUG(channel, "%s: flags %x, size %u", __FUNCTION__,
>                    scursor->flags, scursor->data_size);
> @@ -434,7 +433,7 @@ static display_cursor *set_cursor(SpiceChannel *channel, SpiceCursor *scursor)
>          size /= 2u;
>          for (i = 0; i < hdr->width * hdr->height; i++) {
>              pix_mask = get_pix_mask(data, size, i);
> -            pix = *(SPICE_UNALIGNED_CAST(guint16 *, data) + i);
> +            pix = *((guint16*)data + i);
>              if (pix_mask && pix == 0x7fff) {
>                  cursor->data[i] = get_pix_hack(i, hdr->width);
>              } else {
> @@ -445,11 +444,10 @@ static display_cursor *set_cursor(SpiceChannel *channel, SpiceCursor *scursor)
>          break;
>      case SPICE_CURSOR_TYPE_COLOR4:
>          size = ((unsigned int)(SPICE_ALIGN(hdr->width, 2) / 2)) * hdr->height;
> -        memcpy(palette, data + size, sizeof(palette));
>          for (i = 0; i < hdr->width * hdr->height; i++) {
>              pix_mask = get_pix_mask(data, size + (sizeof(uint32_t) << 4), i);
>              int idx = (i & 1) ? (data[i >> 1] & 0x0f) : ((data[i >> 1] & 0xf0) >> 4);
> -            pix = palette[idx];
> +            pix = *((uint32_t*)(data + size) + idx);
>              if (pix_mask && pix == 0xffffff) {
>                  cursor->data[i] = get_pix_hack(i, hdr->width);
>              } else {
> diff --git a/src/channel-display-mjpeg.c b/src/channel-display-mjpeg.c
> index ee33b01..3ae9d21 100644
> --- a/src/channel-display-mjpeg.c
> +++ b/src/channel-display-mjpeg.c
> @@ -151,7 +151,7 @@ static gboolean mjpeg_decoder_decode_frame(gpointer video_decoder)
>  #ifndef JCS_EXTENSIONS
>          {
>              uint8_t *s = lines[0];
> -            uint32_t *d = SPICE_ALIGNED_CAST(uint32_t *, s);
> +            uint32_t *d = (uint32_t *)s;
>  
>              if (back_compat) {
>                  for (unsigned int j = lines_read * width; j > 0; ) {
> diff --git a/src/channel-main.c b/src/channel-main.c
> index 4edd575..87e621e 100644
> --- a/src/channel-main.c
> +++ b/src/channel-main.c
> @@ -1872,7 +1872,7 @@ static void main_agent_handle_xfer_status(SpiceMainChannel *channel,
>                                      _("The spice agent reported an error during the file transfer"));
>          break;
>      case VD_AGENT_FILE_XFER_STATUS_NOT_ENOUGH_SPACE: {
> -        uint64_t *free_space = SPICE_ALIGNED_CAST(uint64_t *, msg->data);
> +        uint64_t *free_space = (uint64_t *)(msg->data);
>          gchar *free_space_str = g_format_size(*free_space);
>          gchar *file_size_str = g_format_size(spice_file_transfer_task_get_total_bytes(xfer_task));
>          error = g_error_new(SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> diff --git a/src/continuation.h b/src/continuation.h
> index d1fd137..675a257 100644
> --- a/src/continuation.h
> +++ b/src/continuation.h
> @@ -21,7 +21,6 @@
>  #ifndef _CONTINUATION_H_
>  #define _CONTINUATION_H_
>  
> -#include "spice-common.h"
>  #include <stddef.h>
>  #include <ucontext.h>
>  #include <setjmp.h>
> @@ -49,9 +48,8 @@ int cc_release(struct continuation *cc);
>  int cc_swap(struct continuation *from, struct continuation *to);
>  
>  #define offset_of(type, member) ((unsigned long)(&((type *)0)->member))
> -#define container_of(obj, type, member)                                 \
> -        SPICE_ALIGNED_CAST(type *,                                      \
> -                           (((char *)obj) - offset_of(type, member)))
> +#define container_of(obj, type, member) \
> +        (type *)(((char *)obj) - offset_of(type, member))
>  
>  #endif
>  /*
> diff --git a/src/decode-glz-tmpl.c b/src/decode-glz-tmpl.c
> index 76d832c..b337a8b 100644
> --- a/src/decode-glz-tmpl.c
> +++ b/src/decode-glz-tmpl.c
> @@ -178,7 +178,7 @@ static size_t FNAME(decode)(SpiceGlzDecoderWindow *window,
>                              uint64_t image_id, SpicePalette *plt)
>  {
>      uint8_t      *ip = in_buf;
> -    OUT_PIXEL    *out_pix_buf = SPICE_ALIGNED_CAST(OUT_PIXEL *, out_buf);
> +    OUT_PIXEL    *out_pix_buf = (OUT_PIXEL *)out_buf;
>      OUT_PIXEL    *op = out_pix_buf;
>      OUT_PIXEL    *op_limit = out_pix_buf + size;
>  
> diff --git a/src/spice-channel.c b/src/spice-channel.c
> index 418e2b7..77ac9cd 100644
> --- a/src/spice-channel.c
> +++ b/src/spice-channel.c
> @@ -1312,7 +1312,6 @@ static void spice_channel_send_link(SpiceChannel *channel)
>  {
>      SpiceChannelPrivate *c = channel->priv;
>      uint8_t *buffer, *p;
> -    uint32_t *caps;
>      int protocol, i;
>      SpiceLinkMess link_msg;
>  
> @@ -1358,14 +1357,14 @@ static void spice_channel_send_link(SpiceChannel *channel)
>      memcpy(p, &c->link_hdr, sizeof(c->link_hdr)); p += sizeof(c->link_hdr);
>      memcpy(p, &link_msg, sizeof(link_msg)); p += sizeof(link_msg);
>  
> -    caps = SPICE_UNALIGNED_CAST(uint32_t *,p);
>      for (i = 0; i < c->common_caps->len; i++) {
> -        *caps++ = GUINT32_TO_LE(g_array_index(c->common_caps, uint32_t, i));
> +        *(uint32_t *)p = GUINT32_TO_LE(g_array_index(c->common_caps, uint32_t, i));
> +        p += sizeof(uint32_t);
>      }
>      for (i = 0; i < c->caps->len; i++) {
> -        *caps++ = GUINT32_TO_LE(g_array_index(c->caps, uint32_t, i));
> +        *(uint32_t *)p = GUINT32_TO_LE(g_array_index(c->caps, uint32_t, i));
> +        p += sizeof(uint32_t);
>      }
> -    p = (uint8_t *) caps;
>      CHANNEL_DEBUG(channel, "channel type %d id %d num common caps %u num caps %u",
>                    c->channel_type,
>                    c->channel_id,
> @@ -1889,7 +1888,6 @@ static gboolean spice_channel_recv_link_msg(SpiceChannel *channel)
>      SpiceChannelPrivate *c;
>      int rc, num_caps, i;
>      uint32_t *caps, num_channel_caps, num_common_caps;
> -    uint8_t *caps_src;
>      SpiceChannelEvent event = SPICE_CHANNEL_ERROR_LINK;
>  
>      g_return_val_if_fail(channel != NULL, FALSE);
> @@ -1929,21 +1927,18 @@ static gboolean spice_channel_recv_link_msg(SpiceChannel *channel)
>      /* see original spice/client code: */
>      /* g_return_if_fail(c->peer_msg + c->peer_msg->caps_offset * sizeof(uint32_t) > c->peer_msg + c->peer_hdr.size); */
>  
> -    caps_src = (uint8_t *)c->peer_msg + GUINT32_FROM_LE(c->peer_msg->caps_offset);
> +    caps = (uint32_t *)((uint8_t *)c->peer_msg + GUINT32_FROM_LE(c->peer_msg->caps_offset));
> +
>      g_array_set_size(c->remote_common_caps, num_common_caps);
> -    caps = &g_array_index(c->remote_common_caps, uint32_t, 0);
> -    memcpy(caps, caps_src, num_common_caps * sizeof(uint32_t));
>      for (i = 0; i < num_common_caps; i++, caps++) {
> -        *caps = GUINT32_FROM_LE(*caps);
> -        CHANNEL_DEBUG(channel, "got common caps %d:0x%X", i, *caps);
> +        g_array_index(c->remote_common_caps, uint32_t, i) = GUINT32_FROM_LE(*caps);
> +        CHANNEL_DEBUG(channel, "got common caps %d:0x%X", i, GUINT32_FROM_LE(*caps));
>      }
>  
>      g_array_set_size(c->remote_caps, num_channel_caps);
> -    caps_src += num_common_caps * sizeof(uint32_t);
> -    memcpy(caps, caps_src, num_channel_caps * sizeof(uint32_t));
>      for (i = 0; i < num_channel_caps; i++, caps++) {
> -        *caps = GUINT32_FROM_LE(*caps);
> -        CHANNEL_DEBUG(channel, "got channel caps %d:0x%X", i, *caps);
> +        g_array_index(c->remote_caps, uint32_t, i) = GUINT32_FROM_LE(*caps);
> +        CHANNEL_DEBUG(channel, "got channel caps %d:0x%X", i, GUINT32_FROM_LE(*caps));
>      }
>  
>      if (!spice_channel_test_common_capability(channel,
> -- 
> 2.13.0
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/spice-devel

Attachment: signature.asc
Description: PGP signature

_______________________________________________
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]