<html><body><div style="font-family: times new roman, new york, times, serif; font-size: 12pt; color: #000000"><div><br></div><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><div><blockquote class=""><div class="">On 8 Jun 2017, at 12:17, Frediano Ziglio <<a href="mailto:fziglio@redhat.com" class="" target="_blank">fziglio@redhat.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="" class=""><blockquote style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class=""><br class="">From: Christophe de Dinechin <<a href="mailto:dinechin@redhat.com" class="" target="_blank">dinechin@redhat.com</a>><br class=""><br class="">For example, something like this:<br class="">   uint8_t  *p8;<br class="">   uint32_t *p32 = (uint32_t *) p8;<br class=""><br class="">generates a warning like this:<br class=""> spice-channel.c:1350:10: error: cast from 'uint8_t *' (aka 'unsigned char<br class=""> *') to<br class="">     'uint32_t *' (aka 'unsigned int *') increases required alignment from 1<br class="">     to<br class="">     4 [-Werror,-Wcast-align]<br class=""><br class="">The warning indicates that we end up with a pointer to data that<br class="">should be 4-byte aligned, but its value may be misaligned. On x86,<br class="">this does not make much of a difference, except a relatively minor<br class="">performance penalty. However, on platforms such as older ARM, misaligned<br class="">accesses are emulated by the kernel, and support for them is optional.<br class="">So we may end up with a fault.<br class=""><br class="">The intent of the fix here is to make it easy to identify and rework<br class="">places where actual mis-alignment occurs. Wherever casts raise the warning,<br class="">they are replaced with a macro:<br class=""><br class="">- SPICE_ALIGNED_CAST(type, value) casts value to type, and indicates that<br class=""> we believe the resulting pointer is aligned. If it is not, a runtime<br class=""> warning will be issued.<br class=""><br class="">- SPICE_UNALIGNED_CAST(type, value) casts value to type, and indicates that<br class=""> we believe the resulting pointer is not always aligned<br class=""><br class="">Any code using SPICE_UNALIGNED_CAST may need to be revisited in order<br class="">to improve performance, e.g. by using memcpy.<br class=""><br class="">There are normally no warnings for SPICE_UNALIGNED_CAST, but it is possible<br class="">to emit debug messages for mis-alignment in SPICE_UNALIGNED_CAST.<br class="">Set environment variable SPICE_DEBUG_ALIGNMENT to activate this check.<br class=""><br class="">Runtime warnings are enabled by the --enable-alignment-checks configure<br class="">option (or #define SPICE_DEBUG_ALIGNMENT).<br class=""><br class="">Signed-off-by: Christophe de Dinechin <<a href="mailto:dinechin@redhat.com" class="" target="_blank">dinechin@redhat.com</a>><br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Honestly I would start nacking this patch.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Or you disable the warning or you fix it where possible and leave</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">the warning for a time when we'll really need to fix it.</span></div></div></blockquote><div><br class=""></div>Just to clarify, I have already done both.</div><div><br class=""></div><div>- The warning is only enabled if you have —enable-alignment-checks. It’s in the check-in comment above:</div><div><blockquote class=""><div class=""><blockquote class="">Runtime warnings are enabled by the --enable-alignment-checks configure<br class="">option (or #define SPICE_DEBUG_ALIGNMENT).<br class=""></blockquote></div></blockquote><div>So the macros no longer have any cost in the normal case, as you wanted.</div></div></blockquote><div>If is fixed I don't see the point of having any cost even if --enable-alignment-checks is used.<br></div><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><div>- The patch 4/4 is dedicated to fixing some “easy” cases. I understand from your comments here and in response to 4/4 that you’d rather have the “automatic” changes (adding a void *) and the non-automatic ones (e.g. replacing a loop with a memcpy) in the same patch. Is that the general feeling for everybody?</div></blockquote><div>I'd like to have fixes before.<br></div><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><div><blockquote class=""><div class=""><div style="" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Frediano</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">---<br class="">configure.ac                |  8 ++++++++<br class="">spice-common                |  2 +-<br class="">src/channel-cursor.c        |  4 ++--<br class="">src/channel-display-mjpeg.c |  2 +-<br class="">src/channel-main.c          |  2 +-<br class="">src/continuation.h          |  6 ++++--<br class="">src/decode-glz-tmpl.c       |  2 +-<br class="">src/spice-channel.c         | 14 +++++++++-----<br class="">8 files changed, 27 insertions(+), 13 deletions(-)<br class=""><br class="">diff --git a/configure.ac b/configure.ac<br class="">index 62acafc..caa289a 100644<br class="">--- a/configure.ac<br class="">+++ b/configure.ac<br class="">@@ -565,6 +565,14 @@ else<br class="">  SPICE_WARNING([No D-Bus support, desktop integration and USB redirection<br class="">  may not work properly])<br class="">fi<br class=""><br class="">+AC_ARG_ENABLE([alignment-checks],<br class="">+  AS_HELP_STRING([--enable-alignment-checks],<br class="">+                 [Enable runtime checks for cast alignment<br class="">@<:@default=no@:>@]),<br class="">+  [],<br class="">+  enable_alignment_checks="no")<br class="">+AS_IF([test "x$enable_alignment_checks" = "xyes"],<br class="">+      [AC_DEFINE([SPICE_DEBUG_ALIGNMENT], 1, [Enable runtime checks for cast<br class="">alignment])])<br class="">+<br class="">SPICE_CHECK_LZ4<br class=""><br class="">dnl<br class="">===========================================================================<br class="">diff --git a/spice-common b/spice-common<br class="">index af682b1..8cbfedc 160000<br class="">--- a/spice-common<br class="">+++ b/spice-common<br class="">@@ -1 +1 @@<br class="">-Subproject commit af682b1b06dea55007d9aa7c37cd443e4349e43f<br class="">+Subproject commit 8cbfedc08fdf6be68cabd5afd781f61ae01b577b<br class="">diff --git a/src/channel-cursor.c b/src/channel-cursor.c<br class="">index 558c920..80d2410 100644<br class="">--- a/src/channel-cursor.c<br class="">+++ b/src/channel-cursor.c<br class="">@@ -433,7 +433,7 @@ static display_cursor *set_cursor(SpiceChannel *channel,<br class="">SpiceCursor *scursor)<br class="">        size /= 2u;<br class="">        for (i = 0; i < hdr->width * hdr->height; i++) {<br class="">            pix_mask = get_pix_mask(data, size, i);<br class="">-            pix = *((guint16*)data + i);<br class="">+            pix = *(SPICE_ALIGNED_CAST(guint16 *, data) + i);<br class="">            if (pix_mask && pix == 0x7fff) {<br class="">                cursor->data[i] = get_pix_hack(i, hdr->width);<br class="">            } else {<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">we know this is not aligned, either fix or ignore the warning!</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></div></blockquote><div><br class=""></div><div>Hmmm. For some reason, I goofed up, and the fix (marking it UNALIGNED) was integrated in 4/4 instead of 2/4.</div><br class=""><blockquote class=""><div class=""><div style="" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">@@ -447,7 +447,7 @@ static display_cursor *set_cursor(SpiceChannel *channel,<br class="">SpiceCursor *scursor)<br class="">        for (i = 0; i < hdr->width * hdr->height; i++) {<br class="">            pix_mask = get_pix_mask(data, size + (sizeof(uint32_t) << 4),<br class="">            i);<br class="">            int idx = (i & 1) ? (data[i >> 1] & 0x0f) : ((data[i >> 1] &<br class="">            0xf0) >> 4);<br class="">-            pix = *((uint32_t*)(data + size) + idx);<br class="">+            pix = *(SPICE_UNALIGNED_CAST(uint32_t *, (data + size)) + idx);<br class="">            if (pix_mask && pix == 0xffffff) {<br class="">                cursor->data[i] = get_pix_hack(i, hdr->width);<br class="">            } else {<br class=""></blockquote></div></div></blockquote><br class=""><blockquote class=""><div class=""><div style="" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Did you revert the memcpy ??</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></div></blockquote><div><br class=""></div><div>No, it’s in 4/4. I separated the “fixes” from the “detection”.</div><br class=""><blockquote class=""><div class=""><div style="" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">diff --git a/src/channel-display-mjpeg.c b/src/channel-display-mjpeg.c<br class="">index 3ae9d21..ee33b01 100644<br class="">--- a/src/channel-display-mjpeg.c<br class="">+++ b/src/channel-display-mjpeg.c<br class="">@@ -151,7 +151,7 @@ static gboolean mjpeg_decoder_decode_frame(gpointer<br class="">video_decoder)<br class="">#ifndef JCS_EXTENSIONS<br class="">        {<br class="">            uint8_t *s = lines[0];<br class="">-            uint32_t *d = (uint32_t *)s;<br class="">+            uint32_t *d = SPICE_ALIGNED_CAST(uint32_t *, s);<br class=""><br class="">            if (back_compat) {<br class="">                for (unsigned int j = lines_read * width; j > 0; ) {<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Here we are not sure, the warning is fine.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></div></blockquote><div><br class=""></div><div><br class=""></div><br class=""><blockquote class=""><div class=""><div style="" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">diff --git a/src/channel-main.c b/src/channel-main.c<br class="">index 29dd42d..1202d13 100644<br class="">--- a/src/channel-main.c<br class="">+++ b/src/channel-main.c<br class="">@@ -1872,7 +1872,7 @@ static void<br class="">main_agent_handle_xfer_status(SpiceMainChannel *channel,<br class="">                                    _("The spice agent reported an error<br class="">                                    during the file transfer"));<br class="">        break;<br class="">    case VD_AGENT_FILE_XFER_STATUS_NOT_ENOUGH_SPACE: {<br class="">-        uint64_t *free_space = (uint64_t *)(msg->data);<br class="">+        uint64_t *free_space = SPICE_ALIGNED_CAST(uint64_t *, msg->data);<br class="">        gchar *free_space_str = g_format_size(*free_space);<br class="">        gchar *file_size_str =<br class="">        g_format_size(spice_file_transfer_task_get_total_bytes(xfer_task));<br class="">        error = g_error_new(SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">This should be fixed.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></div></blockquote><div><br class=""></div><div>This one is new code since last time I submitted. How should it be fixed? Or are you saying that we know data is unaligned? To me, the structure looks like:</div><div><br class=""></div><div><div>typedef struct SPICE_ATTR_PACKED VDAgentFileXferStatusMessage {</div><div>   uint32_t id;</div><div>   uint32_t result;</div><div>   /* Used to send additional data for detailed error messages</div><div>    * to clients with VD_AGENT_CAP_FILE_XFER_DETAILED_ERRORS capability.</div><div>    * Type of data varies with the result:</div><div>    * result : data type</div><div>    * VD_AGENT_FILE_XFER_STATUS_NOT_ENOUGH_SPACE : uint64_t</div><div>    */</div><div>   uint8_t data[0];</div><div>} VDAgentFileXferStatusMessage;</div><div class=""><br class=""></div><div class="">So at the moment, it seems that data is uint64_t aligned. Do I read incorrectly?</div></div></div></blockquote><div>Yes, and I find really bad you don't see the problem.<br></div><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><div><blockquote class=""><div class=""><div style="" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">diff --git a/src/continuation.h b/src/continuation.h<br class="">index 675a257..d1fd137 100644<br class="">--- a/src/continuation.h<br class="">+++ b/src/continuation.h<br class="">@@ -21,6 +21,7 @@<br class="">#ifndef _CONTINUATION_H_<br class="">#define _CONTINUATION_H_<br class=""><br class="">+#include "spice-common.h"<br class="">#include <stddef.h><br class="">#include <ucontext.h><br class="">#include <setjmp.h><br class="">@@ -48,8 +49,9 @@ int cc_release(struct continuation *cc);<br class="">int cc_swap(struct continuation *from, struct continuation *to);<br class=""><br class="">#define offset_of(type, member) ((unsigned long)(&((type *)0)->member))<br class="">-#define container_of(obj, type, member) \<br class="">-        (type *)(((char *)obj) - offset_of(type, member))<br class="">+#define container_of(obj, type, member)                                 \<br class="">+        SPICE_ALIGNED_CAST(type *,                                      \<br class="">+                           (((char *)obj) - offset_of(type, member)))<br class=""><br class="">#endif<br class="">/*<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">as already explained cast to void* before char*.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></div></blockquote><div><br class=""></div><div>That’s what SPICE_ALIGNED_CAST does. Do you object to documenting that we widen the alignment on purpose here? Or are you still put off by  a runtime check that is no longer there?</div><div><br class=""></div><div>void * does not document anything. I don’t like it.</div></div></blockquote><div>In this case we know it's aligned, the problem is that the macro should cost 0 in all cases.<br></div><div>If you need to check for alignment because you don't understand when is surely aligned it<br></div><div>means you are not trusting the code you are writing. Or I'm entirely not understanding<br></div><div>the purpose of these macros (beside doing cast and silencing the warnings).<br></div><div>Or maybe I lost some changes in the macros?<br></div><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><div><blockquote class=""><div class=""><div style="" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">diff --git a/src/decode-glz-tmpl.c b/src/decode-glz-tmpl.c<br class="">index b337a8b..76d832c 100644<br class="">--- a/src/decode-glz-tmpl.c<br class="">+++ b/src/decode-glz-tmpl.c<br class="">@@ -178,7 +178,7 @@ static size_t FNAME(decode)(SpiceGlzDecoderWindow<br class="">*window,<br class="">                            uint64_t image_id, SpicePalette *plt)<br class="">{<br class="">    uint8_t      *ip = in_buf;<br class="">-    OUT_PIXEL    *out_pix_buf = (OUT_PIXEL *)out_buf;<br class="">+    OUT_PIXEL    *out_pix_buf = SPICE_ALIGNED_CAST(OUT_PIXEL *, out_buf);<br class="">    OUT_PIXEL    *op = out_pix_buf;<br class="">    OUT_PIXEL    *op_limit = out_pix_buf + size;<br class=""><br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">no need to check anything</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></div></blockquote><div><br class=""></div><div>Still need to silence the compiler and document we do this on purpose.</div></div></blockquote><div>Yes, maybe I miss the macro change<br></div><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><div><br class=""><blockquote class=""><div class=""><div style="" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">diff --git a/src/spice-channel.c b/src/spice-channel.c<br class="">index 77ac9cd..3b6d839 100644<br class="">--- a/src/spice-channel.c<br class="">+++ b/src/spice-channel.c<br class="">@@ -1312,6 +1312,7 @@ static void spice_channel_send_link(SpiceChannel<br class="">*channel)<br class="">{<br class="">    SpiceChannelPrivate *c = channel->priv;<br class="">    uint8_t *buffer, *p;<br class="">+    uint32_t *caps;<br class="">    int protocol, i;<br class="">    SpiceLinkMess link_msg;<br class=""><br class="">@@ -1357,14 +1358,15 @@ static void spice_channel_send_link(SpiceChannel<br class="">*channel)<br class="">    memcpy(p, &c->link_hdr, sizeof(c->link_hdr)); p += sizeof(c->link_hdr);<br class="">    memcpy(p, &link_msg, sizeof(link_msg)); p += sizeof(link_msg);<br class=""><br class="">+    // Need this to avoid error with -Wcast-align<br class="">+    caps = SPICE_UNALIGNED_CAST(uint32_t *,p);<br class="">    for (i = 0; i < c->common_caps->len; i++) {<br class="">-        *(uint32_t *)p = GUINT32_TO_LE(g_array_index(c->common_caps,<br class="">uint32_t, i));<br class="">-        p += sizeof(uint32_t);<br class="">+        *caps++ = GUINT32_TO_LE(g_array_index(c->common_caps, uint32_t, i));<br class="">    }<br class="">    for (i = 0; i < c->caps->len; i++) {<br class="">-        *(uint32_t *)p = GUINT32_TO_LE(g_array_index(c->caps, uint32_t, i));<br class="">-        p += sizeof(uint32_t);<br class="">+        *caps++ = GUINT32_TO_LE(g_array_index(c->caps, uint32_t, i));<br class="">    }<br class="">+    p = (uint8_t *) caps;<br class="">    CHANNEL_DEBUG(channel, "channel type %d id %d num common caps %u num<br class="">    caps %u",<br class="">                  c->channel_type,<br class="">                  c->channel_id,<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">why did you revert the fix? It's hard to review patches if you keep</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">going back and forth.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></div></blockquote><div><br class=""></div><div>No, as for the others, the fix is in patch 4/4.</div><br class=""><blockquote class=""><div class=""><div style="" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">@@ -1888,6 +1890,7 @@ static gboolean<br class="">spice_channel_recv_link_msg(SpiceChannel *channel)<br class="">    SpiceChannelPrivate *c;<br class="">    int rc, num_caps, i;<br class="">    uint32_t *caps, num_channel_caps, num_common_caps;<br class="">+    uint8_t *caps_src;<br class="">    SpiceChannelEvent event = SPICE_CHANNEL_ERROR_LINK;<br class=""><br class="">    g_return_val_if_fail(channel != NULL, FALSE);<br class="">@@ -1927,7 +1930,8 @@ static gboolean<br class="">spice_channel_recv_link_msg(SpiceChannel *channel)<br class="">    /* see original spice/client code: */<br class="">    /* g_return_if_fail(c->peer_msg + c->peer_msg->caps_offset *<br class="">    sizeof(uint32_t) > c->peer_msg + c->peer_hdr.size); */<br class=""><br class="">-    caps = (uint32_t *)((uint8_t *)c->peer_msg +<br class="">GUINT32_FROM_LE(c->peer_msg->caps_offset));<br class="">+    caps_src = (uint8_t *)c->peer_msg +<br class="">GUINT32_FROM_LE(c->peer_msg->caps_offset);<br class="">+    caps = SPICE_UNALIGNED_CAST(uint32_t *, caps_src);<br class=""><br class="">    g_array_set_size(c->remote_common_caps, num_common_caps);<br class="">    for (i = 0; i < num_common_caps; i++, caps++) {<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">same</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></div></blockquote><div><br class=""></div><div>Checked that it is in 4/4.</div></div></blockquote><div>Frediano</div><div><br></div></div></body></html>