[Spice-devel] [RFC PATCH spice-gtk] spice-session: Fix SWAP_STR macro

Victor Toso victortoso at redhat.com
Thu Sep 5 13:56:25 UTC 2019


Hi,

On Thu, Sep 05, 2019 at 02:17:07PM +0100, Frediano Ziglio wrote:
> Really swap "x" and "y", not temporary copies.
> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  src/spice-session.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> I didn't test. The main question is why the current code is working?
> Or is migration broken? Or we are not testing the type of migration
> the original swapping code (manual) was supposed to make it work?

If I'm not mistaken, connection already happened at this stage.
Please resend without RFC with some info related to the
introduction of this behavior in 01c6343 "Use macro to swap
data in spice_session_start_migrating()" in 2015-01-29 by
Christophe Fergeau <cfergeau at redhat.com>

> diff --git a/src/spice-session.c b/src/spice-session.c
> index 04ba124a..d0d9e541 100644
> --- a/src/spice-session.c
> +++ b/src/spice-session.c
> @@ -1742,12 +1742,9 @@ void spice_session_switching_disconnect(SpiceSession *self)
>  }
>  
>  #define SWAP_STR(x, y) G_STMT_START { \
> -    const gchar *tmp;                 \
> -    const gchar *a = x;               \
> -    const gchar *b = y;               \
> -    tmp = a;                          \
> -    a = b;                            \
> -    b = tmp;                          \
> +    gchar *tmp = x;                   \
> +    x = y;                            \
> +    y = tmp;                          \
>  } G_STMT_END
>  
>  G_GNUC_INTERNAL
> -- 
> 2.20.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/20190905/dff4a835/attachment-0001.sig>


More information about the Spice-devel mailing list