Skip to content

Conversation

@Thalley
Copy link
Contributor

@Thalley Thalley commented Sep 6, 2025

Modify the ep check functions to have better names and to be more strict, as well as adding a missing function.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors endpoint check functions in the Bluetooth BAP subsystem to have more descriptive names and be more strict in their validation. The changes replace generic "is_" function names with more specific "has_ep" naming conventions and add a missing function for unicast server endpoint validation.

  • Renamed endpoint check functions from bt_bap_ep_is_* to bt_bap_*_has_ep pattern for better clarity
  • Added missing bt_bap_unicast_server_has_ep function and corresponding bt_ascs_has_ep implementation
  • Made endpoint validation more strict by adding proper checks for invalid endpoints

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/bluetooth/audio/cap_initiator/uut/bap_unicast_client.c Updated function name and return value in test stub
tests/bluetooth/audio/ascs/uut/bap_unicast_client.c Updated function name in test stub
subsys/bluetooth/audio/bap_unicast_server.c Added new bt_bap_unicast_server_has_ep function
subsys/bluetooth/audio/bap_unicast_client.c Renamed function from bt_bap_ep_is_unicast_client to bt_bap_unicast_client_has_ep
subsys/bluetooth/audio/bap_stream.c Updated function calls to use new naming convention and added strict endpoint validation
subsys/bluetooth/audio/bap_iso.c Updated function calls to use new naming convention
subsys/bluetooth/audio/bap_internal.h Added function declarations for the new endpoint check functions
subsys/bluetooth/audio/bap_endpoint.h Removed old function declarations
subsys/bluetooth/audio/bap_broadcast_source.c Renamed function and fixed array check macro
subsys/bluetooth/audio/bap_broadcast_sink.c Renamed function and fixed array check macro
subsys/bluetooth/audio/ascs_internal.h Added bt_ascs_has_ep function declaration
subsys/bluetooth/audio/ascs.c Added implementation of bt_ascs_has_ep function

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

bool bt_ascs_has_ep(const struct bt_bap_ep *ep)
{
return PART_OF_ARRAY(ascs.ase_pool, ep);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate of bool bt_ascs_is_ase_ep(const struct bt_bap_ep *ep) (line 1450)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed it is - Thanks for spotting this

We check for all other roles when checking whether
an endpoint can send or receive, except for the unicast server.
It is technically implied, but if the ep is not a valid pointer,
then we may access invalid memory.

Add check for bt_bap_ep_is_unicast_server (which uses the new
bt_ascs_has_ep function).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Rename the bt_bap_is_x_ep functions to better match the
modules where they are implemented.

Additionally modify the check to use IS_ARRAY_ELEMENT
in the broadcast sink and source for a stricter check.
IS_ARRAY_ELEMENT cannot easily be used in the unicast
client and server, as the endpoints are part of another
structure.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@sonarqubecloud
Copy link

@cfriedt cfriedt merged commit 881a242 into zephyrproject-rtos:main Sep 29, 2025
28 checks passed
@github-project-automation github-project-automation bot moved this from In Review to Done in Bluetooth LE Audio Sep 29, 2025
@Thalley Thalley deleted the ep_check_fix branch September 29, 2025 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants