I have several errors like this:

spice-channel.c:1923:12: error: cast from 'uint8_t *' (aka 'unsigned char *') to
      'uint32_t *' (aka 'unsigned int *') increases required alignment from 1 to
      4 [-Werror,-Wcast-align]
  ...(uint32_t *)((uint8_t *)c->peer_msg + 
GUINT32_FROM_LE(c->peer_msg->caps_offset));
     
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Is there any guarantee that the result pointer will be 32-bit aligned? In other 
words, is it guaranteed that the c->peer_msg->caps_offset will be a multiple of 
4? I don’t see this written in the spec.

Based on the answer, the correct fix is:

- If aligned, to cast to a uint32_t * in a way that disables the warning

- If misaligned, to replaced *p with a read operation that is safe when 
mis-aligned (OS dependent I guess)


Thanks
Christophe

_______________________________________________
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel

Reply via email to