2013-11-07 09:31:49

by Jakub Tyszkowski

[permalink] [raw]
Subject: [PATCH 1/2] android: Remove redundant command complete callback

This patch removes command complete callback used only for verbose error
reporting.

---
android/adapter.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/android/adapter.c b/android/adapter.c
index 1d462c8..da5984a 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -625,14 +625,6 @@ static void mgmt_discovering_event(uint16_t index, uint16_t length,
sizeof(cp), &cp, -1);
}

-static void confirm_name_complete(uint8_t status, uint16_t length,
- const void *param, void *user_data)
-{
- if (status != MGMT_STATUS_SUCCESS)
- error("Failed to confirm name: %s (0x%02x)",
- mgmt_errstr(status), status);
-}
-
static void confirm_device_name(const bdaddr_t *addr, uint8_t addr_type)
{
struct mgmt_cp_confirm_name cp;
@@ -642,8 +634,7 @@ static void confirm_device_name(const bdaddr_t *addr, uint8_t addr_type)
cp.addr.type = addr_type;

if (mgmt_reply(adapter->mgmt, MGMT_OP_CONFIRM_NAME, adapter->index,
- sizeof(cp), &cp, confirm_name_complete,
- NULL, NULL) == 0)
+ sizeof(cp), &cp, NULL, NULL, NULL) == 0)
error("Failed to send confirm name request");
}

--
1.8.4.1



2013-11-07 19:51:16

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH 1/2] android: Remove redundant command complete callback

Hi Jakub,

On Thu, Nov 07, 2013, Jakub Tyszkowski wrote:
> This patch removes command complete callback used only for verbose error
> reporting.
>
> ---
> android/adapter.c | 11 +----------
> 1 file changed, 1 insertion(+), 10 deletions(-)

Both patches have been applied. Thanks.

Johan

2013-11-07 09:31:50

by Jakub Tyszkowski

[permalink] [raw]
Subject: [PATCH 2/2] android: Fix sending remote device name property

Android use the full string returned even if terminated with '\0'.

---
android/adapter.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/android/adapter.c b/android/adapter.c
index da5984a..495e725 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -672,9 +672,9 @@ static int fill_device_props(struct hal_property *prop, bdaddr_t *addr,
/* fill name */
if (name) {
prop->type = HAL_PROP_DEVICE_NAME;
- prop->len = HAL_MAX_NAME_LENGTH;
- strncpy((char *) prop->val, name, HAL_MAX_NAME_LENGTH - 1);
- prop = ((void *) prop) + sizeof(*prop) + HAL_MAX_NAME_LENGTH;
+ prop->len = strlen(name);
+ memcpy(prop->val, name, prop->len);
+ prop = ((void *) prop) + sizeof(*prop) + prop->len;
num_props++;
}

@@ -723,7 +723,7 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
props_size += sizeof(struct hal_property) + sizeof(rssi);

if (eir.name)
- props_size += sizeof(struct hal_property) + HAL_MAX_NAME_LENGTH;
+ props_size += sizeof(struct hal_property) + strlen(eir.name);

if (is_new_dev) {
struct hal_ev_device_found *ev = NULL;
--
1.8.4.1