[riot-notifications] [RIOT-OS/RIOT] ble/nimble: add scanlist submodule (#11278)

Martine Lenders notifications at github.com
Wed Mar 27 10:51:18 CET 2019


miri64 commented on this pull request.



> +    if (ble_addr_cmp(&e->addr, addr) == 0) {
+        return 1;
+    }
+    return 0;
+}
+
+static nimble_scanlist_entry_t *_find(const ble_addr_t *addr)
+{
+    return (nimble_scanlist_entry_t *)clist_foreach(&_list, _finder,
+                                                    (void *)addr);
+}
+
+void nimble_scanlist_init(void)
+{
+    for (unsigned i = 0; i < (sizeof(_mem) / sizeof(_mem[0])); i++) {
+        clist_rpush(&_pool, &_mem[i].node);

Can you give a reasoning why you use a list to manage the pool of available nodes instead of just using an array where you search for empty entries by iterating over it? While I certainly like the elegance of this approach, it seem to me to be an unnecessary level of complexity that might introduce bugs when not properly tested (which since there are no unittests provided we can't). 

> + *
+ * @return  the scanlist entry at position @p pos
+ * @return  NULL if there is no entry a the given position
+ */
+nimble_scanlist_entry_t *nimble_scanlist_get_by_pos(unsigned pos);
+
+/**
+ * @brief   Get the next entry from the list, pass NULL for getting the first
+ *          entry
+ *
+ * @param[in] e         any entry in the list
+ *
+ * @return  the entry following @p e
+ * @return  NULL if @p e was the last entry
+ */
+nimble_scanlist_entry_t *nimble_scanlist_get_next(nimble_scanlist_entry_t *e);

It should be mentioned in the documentation that the list might change in between calls of `get_next()` (i.e. that the call is not thread-safe).

> + * @param[in] e         any entry in the list
+ *
+ * @return  the entry following @p e
+ * @return  NULL if @p e was the last entry
+ */
+nimble_scanlist_entry_t *nimble_scanlist_get_next(nimble_scanlist_entry_t *e);
+
+/**
+ * @brief   Clear all entries in the list
+ */
+void nimble_scanlist_clear(void);
+
+/**
+ * @brief   Dump the entire scanlist to STDIO using nimble_scanlist_print_entry()
+ */
+void nimble_scanlist_print(void);

Same here

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11278#pullrequestreview-219353665
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190327/f93c9a5d/attachment.html>


More information about the notifications mailing list