diff options
author | Richard Hughes <richard@hughsie.com> | 2014-05-20 13:25:17 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2014-05-20 13:25:17 +0100 |
commit | 969c97426a868626e8c6289e3a7ff3207fc56624 (patch) | |
tree | 3567339e3796ae839199c5f10fd33ee53efba0d1 | |
parent | 5ed25a7e5f115a71433f137905394ae6b119e450 (diff) | |
download | upower-969c97426a868626e8c6289e3a7ff3207fc56624.tar.gz |
Do not print a critical warning when misusing up_device_set_object_path_sync()
-rw-r--r-- | libupower-glib/up-device.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/libupower-glib/up-device.c b/libupower-glib/up-device.c index 2d65806..9f6e0e1 100644 --- a/libupower-glib/up-device.c +++ b/libupower-glib/up-device.c @@ -125,6 +125,7 @@ gboolean up_device_set_object_path_sync (UpDevice *device, const gchar *object_path, GCancellable *cancellable, GError **error) { UpDeviceGlue *proxy_device; + gboolean ret = TRUE; g_return_val_if_fail (UP_IS_DEVICE (device), FALSE); g_return_val_if_fail (object_path != NULL, FALSE); @@ -132,6 +133,14 @@ up_device_set_object_path_sync (UpDevice *device, const gchar *object_path, GCan if (device->priv->proxy_device != NULL) return FALSE; + /* check valid */ + if (!g_variant_is_object_path (object_path)) { + ret = FALSE; + g_set_error (error, 1, 0, + "Object path invalid: %s", object_path); + goto out; + } + g_clear_pointer (&device->priv->offline_props, g_hash_table_unref); /* connect to the correct path for all the other methods */ @@ -150,8 +159,8 @@ up_device_set_object_path_sync (UpDevice *device, const gchar *object_path, GCan /* yay */ device->priv->proxy_device = proxy_device; - - return TRUE; +out: + return ret; } /** |