Skip to content

Conversation

@Thalley
Copy link
Contributor

@Thalley Thalley commented May 24, 2025

This simplyfies the checks in the function a bit, and makes Sonarcloud happy.

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 range checks in bt_bap_base_get_base_from_ad to use the IN_RANGE macro for clearer bounds validation and to satisfy SonarCloud rules.

  • Replaced manual == 0 || > max checks for subgroup_count, bis_count, and bis_index with IN_RANGE
  • Simplified conditional logic for better readability
Comments suppressed due to low confidence (3)

subsys/bluetooth/audio/bap_base.c:151

  • Consider adding unit tests for boundary values of subgroup_count (1 and BASE_SUBGROUP_MAX_COUNT) as well as out-of-range values to verify the new IN_RANGE check returns NULL when expected.
if (!IN_RANGE(subgroup_count, 1U, BASE_SUBGROUP_MAX_COUNT)) {

subsys/bluetooth/audio/bap_base.c:167

  • Add tests to cover bis_count exactly at the lower and upper limits (1 and BT_ISO_MAX_GROUP_ISO_COUNT) and just outside those limits to ensure the IN_RANGE macro works correctly.
if (!IN_RANGE(bis_count, 1U, BT_ISO_MAX_GROUP_ISO_COUNT)) {

subsys/bluetooth/audio/bap_base.c:205

  • Include unit tests for bis_index boundary values (1 and BT_ISO_BIS_INDEX_MAX) and out-of-range cases to confirm the behavior of the IN_RANGE macro.
if (!IN_RANGE(bis_index, 1U, BT_ISO_BIS_INDEX_MAX)) {

This simplyfies the checks in the function a bit, and makes
Sonarcloud happy.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
@Thalley Thalley force-pushed the sonarcloud_bap_base branch from 278c1ad to 2250856 Compare June 16, 2025 11:41
@sonarqubecloud
Copy link

@kartben kartben requested review from fabiobaltieri and pdgendt June 24, 2025 19:50
@danieldegrasse danieldegrasse merged commit 4adabb4 into zephyrproject-rtos:main Jun 24, 2025
29 checks passed
@github-project-automation github-project-automation bot moved this from In Review to Done in Bluetooth LE Audio Jun 24, 2025
@Thalley Thalley deleted the sonarcloud_bap_base branch June 24, 2025 20:44
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