Re: [PATCH spice-server 04/10] dcc-send: Avoid to use unaligned memory

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

 



Hi,

On Mon, Jan 22, 2018 at 05:54:56PM +0000, Frediano Ziglio wrote:
> This causes some warnings with clang:
> 
> dcc-send.c:1799:28: error: cast from 'uint8_t *' (aka 'unsigned char *') to 'uint32_t *' (aka 'unsigned int *') increases required alignment from 1 to 4 [-Werror,-Wcast-align]
>     num_surfaces_created = (uint32_t *)spice_marshaller_reserve_space(m2, sizeof(uint32_t));
>                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> This also fixes some minor endianness issue (on big endian machine
> integers were not properly encoded).

Not really minor issue, I think :)

> Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>

Acked-by: Victor Toso <victortoso@xxxxxxxxxx>

> ---
>  server/dcc-send.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/server/dcc-send.c b/server/dcc-send.c
> index 364f3405..211c69d7 100644
> --- a/server/dcc-send.c
> +++ b/server/dcc-send.c
> @@ -1793,11 +1793,12 @@ static void display_channel_marshall_migrate_data_surfaces(DisplayChannelClient
>                                                             int lossy)
>  {
>      SpiceMarshaller *m2 = spice_marshaller_get_ptr_submarshaller(m, 0);
> -    uint32_t *num_surfaces_created;
> +    uint32_t num_surfaces_created;
> +    uint8_t *num_surfaces_created_ptr;
>      uint32_t i;
>  
> -    num_surfaces_created = (uint32_t *)spice_marshaller_reserve_space(m2, sizeof(uint32_t));
> -    *num_surfaces_created = 0;
> +    num_surfaces_created_ptr = spice_marshaller_reserve_space(m2, sizeof(uint32_t));
> +    num_surfaces_created = 0;
>      for (i = 0; i < NUM_SURFACES; i++) {
>          SpiceRect lossy_rect;
>  
> @@ -1805,7 +1806,7 @@ static void display_channel_marshall_migrate_data_surfaces(DisplayChannelClient
>              continue;
>          }
>          spice_marshaller_add_uint32(m2, i);
> -        (*num_surfaces_created)++;
> +        num_surfaces_created++;
>  
>          if (!lossy) {
>              continue;
> @@ -1816,6 +1817,7 @@ static void display_channel_marshall_migrate_data_surfaces(DisplayChannelClient
>          spice_marshaller_add_int32(m2, lossy_rect.right);
>          spice_marshaller_add_int32(m2, lossy_rect.bottom);
>      }
> +    spice_marshaller_set_uint32(m2, num_surfaces_created_ptr, num_surfaces_created);
>  }
>  
>  static void display_channel_marshall_migrate_data(RedChannelClient *rcc,
> -- 
> 2.14.3
> 
> _______________________________________________
> 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]