summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2019-10-17 16:43:15 +0200
committerBastien Nocera <hadess@hadess.net>2019-10-17 16:43:15 +0200
commited0dfe4427770776a081877f77f1263491fbe1b6 (patch)
tree8b84335bd0bb4120bc5f2cd5bbb182216782f812
parent8e6cb06ff68a283b9857d4d0e831d93c42521534 (diff)
downloadupower-ed0dfe4427770776a081877f77f1263491fbe1b6.tar.gz
linux: Fix warning when bluez Appearance property isn't setwip/hadess/bluez-memleak
The Appearance property might not be available, and would cause warnings like: upowerd[17733]: g_variant_get_type: assertion 'value != NULL' failed upowerd[17733]: g_variant_type_is_subtype_of: assertion 'g_variant_type_check (type)' failed upowerd[17733]: g_variant_get_uint16: assertion 'g_variant_is_of_type (value, G_VARIANT_TYPE_UINT16)' failed
-rw-r--r--src/linux/up-device-bluez.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/linux/up-device-bluez.c b/src/linux/up-device-bluez.c
index 5e595a9..2074746 100644
--- a/src/linux/up-device-bluez.c
+++ b/src/linux/up-device-bluez.c
@@ -71,7 +71,6 @@ up_device_bluez_coldplug (UpDevice *device)
GDBusProxy *proxy;
GError *error = NULL;
UpDeviceKind kind;
- guint16 appearance;
const char *uuid;
const char *model;
GVariant *v;
@@ -95,9 +94,15 @@ up_device_bluez_coldplug (UpDevice *device)
}
v = g_dbus_proxy_get_cached_property (proxy, "Appearance");
- appearance = g_variant_get_uint16 (v);
- kind = appearance_to_kind (appearance);
- g_variant_unref (v);
+ if (v) {
+ guint16 appearance;
+
+ appearance = g_variant_get_uint16 (v);
+ kind = appearance_to_kind (appearance);
+ g_variant_unref (v);
+ } else {
+ kind = UP_DEVICE_KIND_UNKNOWN;
+ }
v = g_dbus_proxy_get_cached_property (proxy, "Address");
uuid = g_variant_get_string (v, NULL);