linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Santiago Carot <sancane@gmail.com>
To: Anderson Lizardo <anderson.lizardo@openbossa.org>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH 7/8] attrib-server: Allocate 128-bits UUIDs using highest available handlers
Date: Tue, 24 Jan 2012 16:49:13 +0100	[thread overview]
Message-ID: <CACLukz+K6a1gDBuLoLy-90498VNfSu1xY9ciiEfnzW23WeGT4Q@mail.gmail.com> (raw)
In-Reply-To: <CAJdJm_MVOTws3O=czdbQTM4ZxtfLGtgVbkwqS8QPjszq-1-y2w@mail.gmail.com>

Hi Anderson,

2012/1/24 Anderson Lizardo <anderson.lizardo@openbossa.org>:
> Hi Santiago,
>
> On Tue, Jan 24, 2012 at 7:06 AM, Santiago Carot-Nemesio
> <sancane@gmail.com> wrote:
>> 128-uuids services are grouped at the end of the handlers database list.
>> This group grows up from the highest handlers toward lowers handlers
>> until the whole range is used or the last 16 bit-uuid service is reached.
>> ---
>>  src/attrib-server.c |   47 ++++++++++++++++++++++++++++++++++++++++++++++-
>>  1 files changed, 46 insertions(+), 1 deletions(-)
>>
>> diff --git a/src/attrib-server.c b/src/attrib-server.c
>> index e52571c..f2bf5ef 100644
>> --- a/src/attrib-server.c
>> +++ b/src/attrib-server.c
>> @@ -1317,7 +1317,52 @@ static uint16_t find_uuid16_avail(struct btd_adapter *adapter, uint16_t nitems)
>>
>>  static uint16_t find_uuid128_avail(struct btd_adapter *adapter, uint16_t nitems)
>>  {
>> -       /* TODO: Allocate 128 uuids at the end of the list */
>> +       struct gatt_server *server;
>> +       uint16_t handle = 0, end = 0xffff;
>> +       gboolean pick = TRUE;
>> +       GList *dl;
>> +       GSList *l;
>> +
>> +       l = g_slist_find_custom(servers, adapter, adapter_cmp);
>> +       if (l == NULL)
>> +               return 0;
>> +
>> +       server = l->data;
>> +       if (server->database == NULL)
>> +               return 0xffff - nitems + 1;
>> +
>> +       for (dl = g_list_last(server->database); dl; dl = dl->prev) {
>> +               struct attribute *a = dl->data;
>> +               if (pick) {
>> +                       handle = a->handle;
>> +                       pick = FALSE;
>> +               }
>
> I suspect you can get this code a lot simpler without using this
> "pick" variable. Unfortunately, I don't have time to look at this
> further right now.
>
>> +
>> +               if (bt_uuid_cmp(&a->uuid, &prim_uuid) != 0 &&
>> +                               bt_uuid_cmp(&a->uuid, &snd_uuid) != 0)
>> +                       continue;
>
> At this point you know a->uuid is either primary or secondary. So I
> don't think it is necessary to check again below.
>
>> +
>> +               if ((bt_uuid_cmp(&a->uuid, &prim_uuid) == 0 ||
>> +                               bt_uuid_cmp(&a->uuid, &snd_uuid) == 0) &&
>> +                               end - handle >= nitems)
>> +                       return end - nitems + 1;
>
> Same below. At this point, they are guaranteed to be either primary or
> secondary uuids. You only need to check for a->len.
>

Thanks for the feedback, I'll send a new set with the changes suggested.
Regards.

  reply	other threads:[~2012-01-24 15:49 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-24 11:06 GATT service improvements Santiago Carot-Nemesio
2012-01-24 11:06 ` [PATCH 1/8] gatt-service: Add support for 128-bit Bluetooth UUIDs Santiago Carot-Nemesio
2012-01-24 11:06   ` [PATCH 2/8] gatt-service: Move va_end just after processing the argument list Santiago Carot-Nemesio
2012-01-24 11:06     ` [PATCH 3/8] gatt-service: Provide service uuid in attrib_db_find_avail function Santiago Carot-Nemesio
2012-01-24 11:06       ` [PATCH 4/8] attrib-server: Allocate 16-bits UUIDS at the begining of the list Santiago Carot-Nemesio
2012-01-24 11:06         ` [PATCH 5/8] attrib-server: Set database uuids as a double linked list Santiago Carot-Nemesio
2012-01-24 11:06           ` [PATCH 6/8] glib-compat: Add g_list_free_full to deal with issues in old GLib versions Santiago Carot-Nemesio
2012-01-24 11:06             ` [PATCH 7/8] attrib-server: Allocate 128-bits UUIDs using highest available handlers Santiago Carot-Nemesio
2012-01-24 11:06               ` [PATCH 8/8] gatt-example: Fix g_assert checks when an uint16_t value overflows Santiago Carot-Nemesio
2012-01-24 13:48               ` [PATCH 7/8] attrib-server: Allocate 128-bits UUIDs using highest available handlers Anderson Lizardo
2012-01-24 15:49                 ` Santiago Carot [this message]
2012-01-24 12:47         ` [PATCH 4/8] attrib-server: Allocate 16-bits UUIDS at the begining of the list Anderson Lizardo
2012-01-24 12:18       ` [PATCH 3/8] gatt-service: Provide service uuid in attrib_db_find_avail function Anderson Lizardo
2012-01-24 12:03   ` [PATCH 1/8] gatt-service: Add support for 128-bit Bluetooth UUIDs Anderson Lizardo
  -- strict thread matches above, loose matches on Subject: below --
2012-01-25 10:03 GATT improvements v2 Santiago Carot-Nemesio
2012-01-25 10:03 ` [PATCH 1/8] gatt-service: Add support for 128-bit Bluetooth UUIDs Santiago Carot-Nemesio
2012-01-25 10:03   ` [PATCH 2/8] gatt-service: Move va_end just after processing the argument list Santiago Carot-Nemesio
2012-01-25 10:03     ` [PATCH 3/8] gatt-service: Provide service uuid in attrib_db_find_avail function Santiago Carot-Nemesio
2012-01-25 10:03       ` [PATCH 4/8] attrib-server: Allocate 16-bits UUIDS at the begining of the list Santiago Carot-Nemesio
2012-01-25 10:03         ` [PATCH 5/8] attrib-server: Set database uuids as a double linked list Santiago Carot-Nemesio
2012-01-25 10:03           ` [PATCH 6/8] glib-compat: Add g_list_free_full to deal with issues in old GLib versions Santiago Carot-Nemesio
2012-01-25 10:03             ` [PATCH 7/8] attrib-server: Allocate 128-bits UUIDs using highest available handlers Santiago Carot-Nemesio
2012-01-25 13:12 GATT improvements v3 Santiago Carot-Nemesio
2012-01-25 13:12 ` [PATCH 1/8] gatt-service: Add support for 128-bit Bluetooth UUIDs Santiago Carot-Nemesio
2012-01-25 13:12   ` [PATCH 2/8] gatt-service: Move va_end just after processing the argument list Santiago Carot-Nemesio
2012-01-25 13:12     ` [PATCH 3/8] gatt-service: Provide service uuid in attrib_db_find_avail function Santiago Carot-Nemesio
2012-01-25 13:12       ` [PATCH 4/8] attrib-server: Allocate 16-bits UUIDS at the begining of the list Santiago Carot-Nemesio
2012-01-25 13:12         ` [PATCH 5/8] attrib-server: Set database uuids as a double linked list Santiago Carot-Nemesio
2012-01-25 13:12           ` [PATCH 6/8] glib-compat: Add g_list_free_full to deal with issues in old GLib versions Santiago Carot-Nemesio
2012-01-25 13:12             ` [PATCH 7/8] attrib-server: Allocate 128-bits UUIDs using highest available handlers Santiago Carot-Nemesio

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=CACLukz+K6a1gDBuLoLy-90498VNfSu1xY9ciiEfnzW23WeGT4Q@mail.gmail.com \
    --to=sancane@gmail.com \
    --cc=anderson.lizardo@openbossa.org \
    --cc=linux-bluetooth@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).