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.
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