8000 _bleio: inconsistent use of linked lists vs Python lists in Service, Characteristic, and Descriptor · Issue #3228 · adafruit/circuitpython · GitHub
[go: up one dir, main page]

Skip to content
_bleio: inconsistent use of linked lists vs Python lists in Service, Characteristic, and Descriptor #3228
Closed
@dhalbert

Description

@dhalbert
  • Service objects contain a field mp_obj_list_t *characteristic_list, which is meant to be a Python list of Characteristic objects.
  • Characteristic objects contain bleio_descriptor_obj_t *descriptor_list, which is meant to be a linked list of Descriptor objects.
  • Descriptor objects contain struct _bleio_descriptor_obj* next, which is used for the linked list.

But, there's this code:

mp_obj_list_append(m_desc_discovery_characteristic->descriptor_list, MP_OBJ_FROM_PTR(descriptor));

which treats descriptor_list as a Python list. This is bad. Figure out what is wrong.

I have this vague and possibly wrong memory: I think I originally used Python lists, and then decided that I should not do storage allocation in the SD event handlers, and changed to a linked list instead. But clearly this changeover was not done consistently. I think all of these could be linked lists.

The code above is only used for remote Descriptors (it's called in discovery), and the descriptor_list is used as a linked list in common_hal_bleio_characteristic_add_descriptor(), which is for local Descriptors. So perhaps that's this inconsistency is not breaking anything, but it's still not right.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0