[Spice-devel] [spice-gtk Win32 v3 07/12] Windows mingw: usb: implement GUdevDevice & GUdevClient for windows

Uri Lublin uril at redhat.com
Thu Jun 28 06:14:31 PDT 2012


On 06/28/2012 04:46 AM, Uri Lublin wrote:
> +#define INT_RETURN_IF_DIFFERENT(x, y) \
> +    do { gint c,d; c=(x); d=(y); if(c-d) return (c-d); } while(0)
> +
> +static gint gudev_device_compare(GUdevDevice *a, GUdevDevice *b)
> +{
> +    GUdevDeviceInfo *ai, *bi;
> +
> +    g_return_val_if_fail(G_UDEV_DEVICE(a), 1);
> +    g_return_val_if_fail(G_UDEV_DEVICE(b), -1);
> +
> +    ai = a->priv->udevinfo;
> +    bi = b->priv->udevinfo;
> +
> +    INT_RETURN_IF_DIFFERENT(ai->bus, bi->bus);
> +    INT_RETURN_IF_DIFFERENT(ai->addr, bi->addr);
> +    INT_RETURN_IF_DIFFERENT(ai->vid, bi->vid);
> +    INT_RETURN_IF_DIFFERENT(ai->pid, bi->pid);

Probably safer to only compare <bus, addr> and remove <pid, vid>
(in case pid, vid are not initialized).

> +
> +    return 0;
> +}
> +
> +
>



More information about the Spice-devel mailing list