Skip to content

Commit 2140b55

Browse files
Thalleyjhedberg
authored andcommitted
Bluetooth: BAP: Shell: 0-init some global variables
0-init some non-static global variables to avoid issues with uninitialized values. Also modify the printing of the broadcast sources found slightly. Signed-off-by: Emil Gydesen <[email protected]>
1 parent 5bf4af9 commit 2140b55

File tree

1 file changed

+17
-12
lines changed
  • subsys/bluetooth/audio/shell

1 file changed

+17
-12
lines changed

subsys/bluetooth/audio/shell/bap.c

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,24 @@
6161

6262
#if defined(CONFIG_BT_BAP_UNICAST)
6363

64-
struct shell_stream unicast_streams[CONFIG_BT_MAX_CONN *
65-
MAX(UNICAST_SERVER_STREAM_COUNT, UNICAST_CLIENT_STREAM_COUNT)];
64+
struct shell_stream unicast_streams[CONFIG_BT_MAX_CONN * MAX(UNICAST_SERVER_STREAM_COUNT,
65+
UNICAST_CLIENT_STREAM_COUNT)] = {0};
6666

6767
#if defined(CONFIG_BT_BAP_UNICAST_CLIENT)
68-
struct unicast_group default_unicast_group;
68+
struct unicast_group default_unicast_group = {0};
6969
static struct bt_bap_unicast_client_cb unicast_client_cbs;
7070
#if CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT > 0
71-
struct bt_bap_ep *snks[CONFIG_BT_MAX_CONN][CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT];
71+
struct bt_bap_ep *snks[CONFIG_BT_MAX_CONN][CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT] = {0};
7272
#endif /* CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT > 0 */
7373
#if CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT > 0
74-
struct bt_bap_ep *srcs[CONFIG_BT_MAX_CONN][CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT];
74+
struct bt_bap_ep *srcs[CONFIG_BT_MAX_CONN][CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT] = {0};
7575
#endif /* CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT > 0 */
7676
#endif /* CONFIG_BT_BAP_UNICAST_CLIENT */
7777
#endif /* CONFIG_BT_BAP_UNICAST */
7878

7979
#if defined(CONFIG_BT_BAP_BROADCAST_SOURCE)
80-
struct shell_stream broadcast_source_streams[CONFIG_BT_BAP_BROADCAST_SRC_STREAM_COUNT];
81-
struct broadcast_source default_source;
80+
struct shell_stream broadcast_source_streams[CONFIG_BT_BAP_BROADCAST_SRC_STREAM_COUNT] = {0};
81+
struct broadcast_source default_source = {0};
8282
#endif /* CONFIG_BT_BAP_BROADCAST_SOURCE */
8383
#if defined(CONFIG_BT_BAP_BROADCAST_SINK)
8484
static struct shell_stream broadcast_sink_streams[CONFIG_BT_BAP_BROADCAST_SNK_STREAM_COUNT];
@@ -2384,8 +2384,11 @@ static void broadcast_scan_recv(const struct bt_le_scan_recv_info *info, struct
23842384

23852385
bt_addr_le_to_str(info->addr, addr_str, sizeof(addr_str));
23862386

2387-
bt_shell_print("Found broadcaster with ID 0x%06X (%s) and addr %s and sid 0x%02X ",
2388-
sr_info.broadcast_id, sr_info.broadcast_name, addr_str, info->sid);
2387+
bt_shell_print("Found broadcaster with ID 0x%06X (%s) and addr %s and sid 0x%02X (scanning "
2388+
"for 0x%06X (%s))",
2389+
sr_info.broadcast_id, sr_info.broadcast_name, addr_str, info->sid,
2390+
auto_scan.broadcast_info.broadcast_id,
2391+
auto_scan.broadcast_info.broadcast_name);
23892392

23902393
if ((auto_scan.broadcast_info.broadcast_id == BT_BAP_INVALID_BROADCAST_ID) &&
23912394
(strlen(auto_scan.broadcast_info.broadcast_name) == 0U)) {
@@ -2399,11 +2402,13 @@ static void broadcast_scan_recv(const struct bt_le_scan_recv_info *info, struct
23992402
is_substring(auto_scan.broadcast_info.broadcast_name, sr_info.broadcast_name)) {
24002403
auto_scan.broadcast_info.broadcast_id = sr_info.broadcast_id;
24012404
identified_broadcast = true;
2402-
2403-
bt_shell_print("Found matched broadcast name '%s' with address %s",
2404-
sr_info.broadcast_name, addr_str);
2405+
} else {
2406+
/* no op */
2407+
return;
24052408
}
24062409

2410+
bt_shell_print("Found matched broadcast with address %s", addr_str);
2411+
24072412
if (identified_broadcast && (auto_scan.broadcast_sink != NULL) &&
24082413
(auto_scan.broadcast_sink->pa_sync == NULL)) {
24092414
struct bt_le_per_adv_sync_param create_params = {0};

0 commit comments

Comments
 (0)