[Spice-commits] 3 commits - src/channel-usbredir.c src/usb-device-manager.c src/win-usb-dev.c src/win-usb-dev.h
Victor Toso de Carvalho
victortoso at kemper.freedesktop.org
Tue Nov 15 13:17:51 UTC 2016
src/channel-usbredir.c | 6 +++++-
src/usb-device-manager.c | 2 +-
src/win-usb-dev.c | 11 +++++------
src/win-usb-dev.h | 2 +-
4 files changed, 12 insertions(+), 9 deletions(-)
New commits:
commit d3c29773b1654085ef6653643b1f790985b8454b
Author: Victor Toso <me at victortoso.com>
Date: Mon Nov 14 23:35:17 2016 +0100
channel-usbredir: handle failure from SpiceUsbDeviceManager
As spice_usb_device_manager_get() can be NULL
Signed-off-by: Victor Toso <victortoso at redhat.com>
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
diff --git a/src/channel-usbredir.c b/src/channel-usbredir.c
index add7d5e..4837d68 100644
--- a/src/channel-usbredir.c
+++ b/src/channel-usbredir.c
@@ -293,6 +293,7 @@ static gboolean spice_usbredir_channel_open_device(
SpiceSession *session;
libusb_device_handle *handle = NULL;
int rc, status;
+ SpiceUsbDeviceManager *manager;
g_return_val_if_fail(priv->state == STATE_DISCONNECTED
#ifdef USE_POLKIT
@@ -317,7 +318,10 @@ static gboolean spice_usbredir_channel_open_device(
}
session = spice_channel_get_session(SPICE_CHANNEL(channel));
- priv->usb_device_manager = g_object_ref(spice_usb_device_manager_get(session, NULL));
+ manager = spice_usb_device_manager_get(session, NULL);
+ g_return_val_if_fail(manager != NULL, FALSE);
+
+ priv->usb_device_manager = g_object_ref(manager);
if (!spice_usb_device_manager_start_event_listening(priv->usb_device_manager, err)) {
usbredirhost_set_device(priv->host, NULL);
return FALSE;
commit eba83a7056d4213b60466f692a03e515115b0826
Author: Victor Toso <me at victortoso.com>
Date: Mon Nov 14 18:37:56 2016 +0100
win-usb-dev: report error to g_udev_client_new()
Otherwise application will not be able to know the reason for failure.
Signed-off-by: Victor Toso <victortoso at redhat.com>
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c
index 6f9ed5d..3d4bd98 100644
--- a/src/usb-device-manager.c
+++ b/src/usb-device-manager.c
@@ -320,7 +320,7 @@ static gboolean spice_usb_device_manager_initable_init(GInitable *initable,
/* Start listening for usb devices plug / unplug */
#ifdef USE_GUDEV
- priv->udev = g_udev_client_new(subsystems);
+ priv->udev = g_udev_client_new(subsystems, err);
g_signal_connect(G_OBJECT(priv->udev), "uevent",
G_CALLBACK(spice_usb_device_manager_uevent_cb), self);
/* Do coldplug (detection of already connected devices) */
diff --git a/src/win-usb-dev.c b/src/win-usb-dev.c
index a857b02..4b95b2d 100644
--- a/src/win-usb-dev.c
+++ b/src/win-usb-dev.c
@@ -106,12 +106,12 @@ GQuark g_udev_client_error_quark(void)
return g_quark_from_static_string("win-gudev-client-error-quark");
}
-GUdevClient *g_udev_client_new(const gchar* const *subsystems)
+GUdevClient *g_udev_client_new(const gchar* const *subsystems, GError **error)
{
if (singleton != NULL)
return g_object_ref(singleton);
- singleton = g_initable_new(G_UDEV_TYPE_CLIENT, NULL, NULL, NULL);
+ singleton = g_initable_new(G_UDEV_TYPE_CLIENT, NULL, error, NULL);
return singleton;
}
diff --git a/src/win-usb-dev.h b/src/win-usb-dev.h
index b5c4fce..a9562ab 100644
--- a/src/win-usb-dev.h
+++ b/src/win-usb-dev.h
@@ -79,7 +79,7 @@ struct _GUdevClientClass
};
GType g_udev_client_get_type(void) G_GNUC_CONST;
-GUdevClient *g_udev_client_new(const gchar* const *subsystems);
+GUdevClient *g_udev_client_new(const gchar* const *subsystems, GError **error);
GList *g_udev_client_query_by_subsystem(GUdevClient *client, const gchar *subsystem);
GType g_udev_device_get_type(void) G_GNUC_CONST;
commit 82ed594a0143370630d6d71ac484d66475cdb96c
Author: Victor Toso <me at victortoso.com>
Date: Tue Nov 15 00:03:20 2016 +0100
win-usb-dev: make usage of early return
No need for if else here.
Signed-off-by: Victor Toso <victortoso at redhat.com>
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
diff --git a/src/win-usb-dev.c b/src/win-usb-dev.c
index 1cf9f21..a857b02 100644
--- a/src/win-usb-dev.c
+++ b/src/win-usb-dev.c
@@ -108,12 +108,11 @@ GQuark g_udev_client_error_quark(void)
GUdevClient *g_udev_client_new(const gchar* const *subsystems)
{
- if (!singleton) {
- singleton = g_initable_new(G_UDEV_TYPE_CLIENT, NULL, NULL, NULL);
- return singleton;
- } else {
+ if (singleton != NULL)
return g_object_ref(singleton);
- }
+
+ singleton = g_initable_new(G_UDEV_TYPE_CLIENT, NULL, NULL, NULL);
+ return singleton;
}
More information about the Spice-commits
mailing list