[Spice-devel] [PATCH spice-server] reds: Remove possible alignment warning using Clang

Christophe Fergeau cfergeau at redhat.com
Mon Jun 18 12:18:00 UTC 2018


Acked-by: Christophe Fergeau <cfergeau at redhat.com>

On Mon, Jun 18, 2018 at 10:38:53AM +0100, Frediano Ziglio wrote:
> Although capabilities inside link message are handled as arrays
> of 4 bytes unsigned integers we don't need capabilities to be
> aligned to 4 bytes just to call g_memdup so use a pointer to
> uint8_t instead.
> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  server/reds.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/server/reds.c b/server/reds.c
> index 935448d8..66a221c3 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -1758,7 +1758,7 @@ static void
>  red_channel_capabilities_init_from_link_message(RedChannelCapabilities *caps,
>                                                  const SpiceLinkMess *link_mess)
>  {
> -    const uint32_t *raw_caps = (uint32_t *)((uint8_t *)link_mess + link_mess->caps_offset);
> +    const uint8_t *raw_caps = (const uint8_t *)link_mess + link_mess->caps_offset;
>  
>      caps->num_common_caps = link_mess->num_common_caps;
>      caps->common_caps = NULL;
> @@ -1769,7 +1769,7 @@ red_channel_capabilities_init_from_link_message(RedChannelCapabilities *caps,
>      caps->num_caps = link_mess->num_channel_caps;
>      caps->caps = NULL;
>      if (link_mess->num_channel_caps) {
> -        caps->caps = g_memdup(raw_caps + link_mess->num_common_caps,
> +        caps->caps = g_memdup(raw_caps + link_mess->num_common_caps * sizeof(uint32_t),
>                                link_mess->num_channel_caps * sizeof(uint32_t));
>      }
>  }
> -- 
> 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/42b2d83d/attachment.sig>


More information about the Spice-devel mailing list