From: Tyszkowski Jakub <jakub.tyszkowski@tieto.com>
To: Szymon Janc <szymon.janc@tieto.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH 05/10] android/gatt: Use g_attrib_send consistently
Date: Fri, 13 Feb 2015 13:49:22 +0100 [thread overview]
Message-ID: <54DDF2D2.5030804@tieto.com> (raw)
In-Reply-To: <2715406.EyNz60MSyF@uw000953>
Hi Szymon,
On 13.02.2015 12:31, Szymon Janc wrote:
> Hi Jakub,
>
> On Wednesday 11 of February 2015 15:34:03 Jakub Tyszkowski wrote:
>> 'g_attrib_send' do checks the 'length' parameter so there is no need
>> for us to do this (and in most cases we don't). We can test the
>> returned value in case we want to report error.
>> ---
>> android/gatt.c | 31 +++++++++++--------------------
>> 1 file changed, 11 insertions(+), 20 deletions(-)
>>
>> diff --git a/android/gatt.c b/android/gatt.c
>> index 7f95226..81b0283 100644
>> --- a/android/gatt.c
>> +++ b/android/gatt.c
>> @@ -1068,9 +1068,7 @@ static void notify_att_range_change(struct gatt_device *dev,
>> break;
>> }
>>
>> - if (length)
>> - g_attrib_send(dev->attrib, 0, pdu, length,
>> - confirmation_cb, NULL, NULL);
>> + g_attrib_send(dev->attrib, 0, pdu, length, confirmation_cb, NULL, NULL);
>> }
>>
>> static struct app_connection *create_connection(struct gatt_device *device,
>> @@ -1480,9 +1478,7 @@ static void ind_handler(const uint8_t *cmd, uint16_t cmd_len,
>> */
>>
>> resp_length = enc_confirmation(opdu, length);
>> - if (resp_length)
>> - g_attrib_send(dev->attrib, 0, opdu, resp_length, NULL, NULL,
>> - NULL);
>> + g_attrib_send(dev->attrib, 0, opdu, resp_length, NULL, NULL, NULL);
>> }
>>
>> static void connect_cb(GIOChannel *io, GError *gerr, gpointer user_data)
>> @@ -4157,12 +4153,10 @@ static uint8_t test_read_write(bdaddr_t *bdaddr, bt_uuid_t *uuid, uint16_t op,
>> return HAL_STATUS_UNSUPPORTED;
>> }
>>
>> - if (!length)
>> + if (!g_attrib_send(dev->attrib, 0, pdu, length, test_command_result,
>> + NULL, NULL))
>> return HAL_STATUS_FAILED;
>>
>> - g_attrib_send(dev->attrib, 0, pdu, length, test_command_result, NULL,
>> - NULL);
>> -
>> return HAL_STATUS_SUCCESS;
>> }
>>
>> @@ -5531,12 +5525,11 @@ static void handle_server_send_indication(const void *buf, uint16_t len)
>> cmd->len, pdu, mtu);
>> }
>>
>> - if (length == 0) {
>> - error("gatt: Failed to encode indication");
>> + if (!g_attrib_send(conn->device->attrib, 0, pdu, length,
>> + confirmation_cb, UINT_TO_PTR(conn->id), NULL)) {
>> + error("gatt: Failed to send indication");
>> status = HAL_STATUS_FAILED;
>> } else {
>> - g_attrib_send(conn->device->attrib, 0, pdu, length,
>> - confirmation_cb, UINT_TO_PTR(conn->id), NULL);
>> status = HAL_STATUS_SUCCESS;
>> }
>>
>> @@ -6143,13 +6136,13 @@ static uint8_t mtu_att_handle(const uint8_t *cmd, uint16_t cmd_len,
>>
>> rsp = g_attrib_get_buffer(dev->attrib, &length);
>>
>> + return ATT_ECODE_UNLIKELY;
>> +
>
> This looks strange, rebase artifact perhaps?
Yeap, I'll resend this patch.
>
>> /* Respond with our MTU */
>> len = enc_mtu_resp(mtu, rsp, length);
>> - if (!len)
>> + if (!g_attrib_send(dev->attrib, 0, rsp, len, NULL, NULL, NULL))
>> return ATT_ECODE_UNLIKELY;
>>
>> - g_attrib_send(dev->attrib, 0, rsp, len, NULL, NULL, NULL);
>> -
>> return 0;
>> }
>>
>> @@ -6703,9 +6696,7 @@ done:
>> resp_length = enc_error_resp(ipdu[0], 0x0000, status, opdu,
>> length);
>>
>> - if (resp_length)
>> - g_attrib_send(dev->attrib, 0, opdu, resp_length, NULL, NULL,
>> - NULL);
>> + g_attrib_send(dev->attrib, 0, opdu, resp_length, NULL, NULL, NULL);
>> }
>>
>> static void connect_confirm(GIOChannel *io, void *user_data)
>>
>
BR,
Jakub
next prev parent reply other threads:[~2015-02-13 12:49 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-11 14:33 [PATCH 01/10] android/gatt: Replace request state with boolean Jakub Tyszkowski
2015-02-11 14:34 ` [PATCH 02/10] android/gatt: Destroy app connections before destroying apps Jakub Tyszkowski
2015-02-11 14:34 ` [PATCH 03/10] android/gatt: Simplify app disconnection function call flow Jakub Tyszkowski
2015-02-11 14:34 ` [PATCH 04/10] android/gatt: Make struct destructors NULL proof Jakub Tyszkowski
2015-02-11 14:34 ` [PATCH 05/10] android/gatt: Use g_attrib_send consistently Jakub Tyszkowski
2015-02-13 11:31 ` Szymon Janc
2015-02-13 12:49 ` Tyszkowski Jakub [this message]
2015-02-11 14:34 ` [PATCH 06/10] android/gatt: Improve send_dev_complete_response Jakub Tyszkowski
2015-02-11 14:34 ` [PATCH 07/10] android/gatt: Improve send_dev_complete_response even further Jakub Tyszkowski
2015-02-13 11:35 ` Szymon Janc
2015-02-13 13:38 ` Tyszkowski Jakub
2015-02-11 14:34 ` [PATCH 08/10] android/gatt: Remove not needed checks and jumps Jakub Tyszkowski
2015-02-11 14:34 ` [PATCH 09/10] android/gatt: Remove redundant matching function Jakub Tyszkowski
2015-02-11 14:34 ` [PATCH 10/10] android/gatt: Avoid copying pointers in matching functions Jakub Tyszkowski
2015-02-13 11:48 ` Szymon Janc
2015-02-13 13:25 ` Tyszkowski Jakub
2015-02-13 11:49 ` [PATCH 01/10] android/gatt: Replace request state with boolean Szymon Janc
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54DDF2D2.5030804@tieto.com \
--to=jakub.tyszkowski@tieto.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=szymon.janc@tieto.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.