Re: [PATCH 1/6] Manage GATT attribute indications in handle callback.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 09.11.2011 14:30, schrieb Anderson Lizardo:
Hi Hendrik,

On Wed, Nov 9, 2011 at 8:54 AM, Hendrik Sattler
<post@xxxxxxxxxxxxxxxxxx> 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@xxxxxxxxx> 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).

Kind of a lazy approach, no?
Ah well...

HS

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux