[Spice-devel] [PATCH spice-server 04/10] dcc-send: Avoid to use unaligned memory
Frediano Ziglio
fziglio at redhat.com
Mon Jan 22 17:54:56 UTC 2018
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).
Signed-off-by: Frediano Ziglio <fziglio 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
More information about the Spice-devel
mailing list