]> code.delx.au - pulseaudio/blobdiff - src/modules/bluetooth/bluez5-util.c
Fix a few "it's -> its" typos
[pulseaudio] / src / modules / bluetooth / bluez5-util.c
index 73e65d1f369fe98844689f377b64e9c269dd8c92..4d1111d2563133db9a67809bafe9a4e2c7e383b8 100644 (file)
@@ -395,8 +395,8 @@ pa_bluetooth_device* pa_bluetooth_discovery_get_device_by_address(pa_bluetooth_d
     pa_assert(local);
 
     while ((d = pa_hashmap_iterate(y->devices, &state, NULL)))
-        if (pa_streq(d->address, remote) && pa_streq(d->adapter->address, local))
-            return d->device_info_valid == 1 ? d : NULL;
+        if (d->device_info_valid == 1 && pa_streq(d->address, remote) && pa_streq(d->adapter->address, local))
+            return d;
 
     return NULL;
 }
@@ -424,6 +424,7 @@ static void device_free(pa_bluetooth_device *d) {
     pa_xfree(d->path);
     pa_xfree(d->alias);
     pa_xfree(d->address);
+    pa_xfree(d->adapter_path);
     pa_xfree(d);
 }
 
@@ -477,8 +478,10 @@ static void adapter_free(pa_bluetooth_adapter *a) {
     pa_assert(a->discovery);
 
     PA_HASHMAP_FOREACH(d, a->discovery->devices, state)
-        if (d->adapter == a)
+        if (d->adapter == a) {
+            set_device_info_valid(d, -1);
             d->adapter = NULL;
+        }
 
     pa_xfree(a->path);
     pa_xfree(a->address);
@@ -818,8 +821,8 @@ static void parse_interfaces_and_properties(pa_bluetooth_discovery *y, DBusMessa
 
         if (!d->adapter && d->adapter_path) {
             d->adapter = pa_hashmap_get(d->discovery->adapters, d->adapter_path);
-            if (!d->adapter) {
-                pa_log_error("Device %s is child of nonexistent adapter %s", d->path, d->adapter_path);
+            if (!d->adapter || !d->adapter->address) {
+                pa_log_error("Device %s is child of nonexistent or corrupted adapter %s", d->path, d->adapter_path);
                 set_device_info_valid(d, -1);
             } else
                 set_device_info_valid(d, 1);
@@ -1230,7 +1233,7 @@ static DBusMessage *endpoint_set_configuration(DBusConnection *conn, DBusMessage
             goto fail2;
         }
     } else {
-        /* InterfacesAdded signal is probably on it's way, device_info_valid is kept as 0. */
+        /* InterfacesAdded signal is probably on its way, device_info_valid is kept as 0. */
         pa_log_warn("SetConfiguration() received for unknown device %s", dev_path);
         d = device_create(y, dev_path);
     }