[Spice-devel] [PATCH spice-common] quic: Prevent side effects calling C macros
Victor Toso
victortoso at redhat.com
Mon Sep 10 08:42:24 UTC 2018
On Fri, Sep 07, 2018 at 04:28:13PM +0100, Frediano Ziglio wrote:
> In some architectures GLib macros to change endianness use the
> argument multiple times causing possible side effects.
>
> This happens for instance using Debian SID and MIPS.
>
> This fixes https://gitlab.freedesktop.org/spice/spice-common/issues/1.
>
> Reported-by: Laurent Bigonville <bigon at debian.org>
> Tested-by: Laurent Bigonville <bigon at debian.org>
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Victor Toso <victortoso at redhat.com>
> ---
> common/quic.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/common/quic.c b/common/quic.c
> index 60818c2..c28974e 100644
> --- a/common/quic.c
> +++ b/common/quic.c
> @@ -452,7 +452,8 @@ static inline void read_io_word(Encoder *encoder)
> if (spice_extra_checks) {
> spice_assert(encoder->io_now < encoder->io_end);
> }
> - encoder->io_next_word = GUINT32_FROM_LE(*(encoder->io_now++));
> + encoder->io_next_word = GUINT32_FROM_LE(*(encoder->io_now));
> + encoder->io_now++;
> }
>
> static inline void decode_eatbits(Encoder *encoder, int len)
> @@ -585,7 +586,8 @@ static int decode_state_run(Encoder *encoder, CommonState *state)
>
> static inline void init_decode_io(Encoder *encoder)
> {
> - encoder->io_next_word = encoder->io_word = GUINT32_FROM_LE(*(encoder->io_now++));
> + encoder->io_next_word = encoder->io_word = GUINT32_FROM_LE(*(encoder->io_now));
> + encoder->io_now++;
> encoder->io_available_bits = 0;
> }
>
> --
> 2.17.1
>
> _______________________________________________
> 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/20180910/e56a50df/attachment.sig>
More information about the Spice-devel
mailing list