From: Anderson Lizardo <anderson.lizardo@openbossa.org>
To: Hendrik Sattler <post@hendrik-sattler.de>
Cc: Santiago Carot-Nemesio <sancane@gmail.com>,
linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH 1/6] Manage GATT attribute indications in handle callback.
Date: Wed, 9 Nov 2011 09:30:02 -0400 [thread overview]
Message-ID: <CAJdJm_PDwZNJM2Ws2=bO_kF=vVASaBY3nPjEDgS3xWqLtPXv+A@mail.gmail.com> (raw)
In-Reply-To: <61c23c74e4beaa75fd2cf48a13012190@mail.hendrik-sattler.de>
Hi Hendrik,
On Wed, Nov 9, 2011 at 8:54 AM, Hendrik Sattler <post@hendrik-sattler.de> wrote:
> Am 09.11.2011 13:00, schrieb Anderson Lizardo:
>>
>> Hi Santiago,
>>
>> On Wed, Nov 9, 2011 at 6:51 AM, Santiago Carot-Nemesio
>> <sancane@gmail.com> wrote:
>>>
>>> +static gint cmp_char_val_handle(gconstpointer a, gconstpointer b)
>>> +{
>>> + const struct characteristic *ch = a;
>>> + const uint16_t *handle = b;
>>> +
>>> + if (ch->attr.value_handle == *handle)
>>> + return 0;
>>> +
>>> + return -1;
>>> +}
>>
>> Usually we implement the function above as:
>>
>> return ch->attr.value_handle - *handle;
>>
>> It will work exactly as your code.
>
> You can do it this way with signed integers but not with unsigned integers,
> unless you cast both to signed first.
> Still, the above code completely misses the +1 case.
The idea here is to return 0 if they are same or non zero if they are
not same. The actual sign is not relevant because the comparison is
for finding items, not sorting them (in this case).
Regards,
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
next prev parent reply other threads:[~2011-11-09 13:30 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-09 10:51 Health Thermometer Profile (HTP) Santiago Carot-Nemesio
2011-11-09 10:51 ` [PATCH 1/6] Manage GATT attribute indications in handle callback Santiago Carot-Nemesio
2011-11-09 10:51 ` [PATCH 2/6] Parse final measurement indication Santiago Carot-Nemesio
2011-11-09 10:52 ` [PATCH 3/6] Add org.bluez.ThermometerWatcher interface to default policy Santiago Carot-Nemesio
2011-11-09 10:52 ` [PATCH 4/6] Implement EnableIntermediateMeasurement D-Bus method Santiago Carot-Nemesio
2011-11-09 10:52 ` [PATCH 5/6] Implement DisableIntermediateMeasurement " Santiago Carot-Nemesio
2011-11-09 10:52 ` [PATCH 6/6] Notify intermediate measurements Santiago Carot-Nemesio
2011-11-09 12:17 ` Anderson Lizardo
2011-11-09 14:49 ` Santiago Carot
2011-11-09 12:00 ` [PATCH 1/6] Manage GATT attribute indications in handle callback Anderson Lizardo
2011-11-09 12:54 ` Hendrik Sattler
2011-11-09 13:30 ` Anderson Lizardo [this message]
2011-11-09 13:53 ` Hendrik Sattler
2011-11-09 14:17 ` Anderson Lizardo
2011-11-09 14:44 ` Santiago Carot
2011-11-09 15:40 ` Anderson Lizardo
2011-11-09 16:50 ` Santiago Carot
2011-11-09 12:19 ` Health Thermometer Profile (HTP) Anderson Lizardo
2011-11-09 14:03 ` Santiago Carot
-- strict thread matches above, loose matches on Subject: below --
2011-11-10 11:36 Santiago Carot-Nemesio
2011-11-10 11:36 ` [PATCH 1/6] Manage GATT attribute indications in handle callback Santiago Carot-Nemesio
2011-11-14 12:11 Health Thermometer Profile (HTP) Santiago Carot-Nemesio
2011-11-14 12:11 ` [PATCH 1/6] Manage GATT attribute indications in handle callback 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='CAJdJm_PDwZNJM2Ws2=bO_kF=vVASaBY3nPjEDgS3xWqLtPXv+A@mail.gmail.com' \
--to=anderson.lizardo@openbossa.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=post@hendrik-sattler.de \
--cc=sancane@gmail.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 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).