[Spice-devel] [PATCH spice-server 04/10] dcc-send: Avoid to use unaligned memory
Victor Toso
victortoso at redhat.com
Mon Jan 29 13:55:28 UTC 2018
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 at redhat.com>
Acked-by: Victor Toso <victortoso at redhat.com>
> ---
> 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 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/20180129/c4c9bf9b/attachment.sig>
More information about the Spice-devel
mailing list