Return-Path: From: Claudio Takahasi To: linux-bluetooth@vger.kernel.org Cc: Claudio Takahasi Subject: [PATCH 10/13] Change the order to write/read the remote's name Date: Thu, 28 Apr 2011 19:37:06 -0300 Message-Id: <1304030229-6672-11-git-send-email-claudio.takahasi@openbossa.org> In-Reply-To: <1304030229-6672-1-git-send-email-claudio.takahasi@openbossa.org> References: <1304030229-6672-1-git-send-email-claudio.takahasi@openbossa.org> Sender: linux-bluetooth-owner@vger.kernel.org List-ID: When discovering, write the EIR "complete" name first before to read the name. Only names retrieved from EIR "complete" name and HCI Remote Name Request Complete event are stored. This patch doesn't change the final result: the value of the name sent in the signal. --- src/adapter.c | 19 +++++-------------- 1 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index f96c115..7fb92e3 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -3127,7 +3127,6 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr, char *name; gboolean new_dev, legacy, le; name_status_t name_status = NAME_NOT_REQUIRED; - const char *dev_name; int err, type; memset(&eir_data, 0, sizeof(eir_data)); @@ -3137,6 +3136,9 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr, return; } + if (eir_data.name != NULL && eir_data.name_complete) + write_device_name(&adapter->bdaddr, bdaddr, eir_data.name); + name = read_stored_data(&adapter->bdaddr, bdaddr, "names"); switch (bda_type) { @@ -3162,23 +3164,12 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr, break; } - /* Complete EIR names are always used. Shortened EIR names are only - * used if there is no name already in storage. */ - dev_name = name; - if (eir_data.name != NULL) { - if (eir_data.name_complete) { - write_device_name(&adapter->bdaddr, bdaddr, - eir_data.name); - name_status = NAME_NOT_REQUIRED; - dev_name = eir_data.name; - } else if (name == NULL) - dev_name = eir_data.name; - } - dev = get_found_dev(adapter, bdaddr, &new_dev); if (new_dev) { + const char *dev_name = (name ? name : eir_data.name); char *alias; + if (dev_name) dev->name = g_strdup(dev_name); -- 1.7.5.rc3