summaryrefslogblamecommitdiffstats
path: root/source/a/upower/patches/0003-linux-Fix-warning-when-bluez-Appearance-property-isn.patch
blob: 156631a7fbaf524aa317c4ebd4cbd4bb278bc254 (plain) (tree)
















































                                                                                                            
From ed0dfe4427770776a081877f77f1263491fbe1b6 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Thu, 17 Oct 2019 16:43:15 +0200
Subject: [PATCH 3/7] linux: Fix warning when bluez Appearance property isn't
 set

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
---
 src/linux/up-device-bluez.c | 13 +++++++++----
 1 file 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);
-- 
2.24.1