From 8f021d49689ddb90dc6d46dc4d0125c30ff18d47 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Fri, 4 Jan 2013 12:06:42 -0800 Subject: [PATCH] core: Remove stupid adapter path string duplication Duplicating the path string before calling g_dbus_unregister_interface is silly. If this is really needed, then there is a bug in the way how the D-Bus interface unregistration is handled. If this causes a bug to show up, then lets fix it at the root of it and not keep working around it. --- src/adapter.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index 0370358d1..e969c4877 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -2012,22 +2012,20 @@ struct btd_adapter *btd_adapter_ref(struct btd_adapter *adapter) void btd_adapter_unref(struct btd_adapter *adapter) { - char *path; - if (__sync_sub_and_fetch(&adapter->ref_count, 1)) return; if (!adapter->path) { + DBG("Freeing adapter %u", adapter->dev_id); + adapter_free(adapter); return; } - path = g_strdup(adapter->path); + DBG("Freeing adapter %s", adapter->path); g_dbus_unregister_interface(btd_get_dbus_connection(), - path, ADAPTER_INTERFACE); - - g_free(path); + adapter->path, ADAPTER_INTERFACE); } static void convert_names_entry(char *key, char *value, void *user_data) -- 2.47.3