Skip to content

Commit 7597939

Browse files
Vudentzjhedberg
authored andcommitted
Bluetooth: shell: Fix illegal access
BT_LE_ADV_CONN_DIR_LOW_DUTY declares a local variable so it cannot go out of scope, so instead of assigning in the scope of the if statement this rework the code to mantain the declaration in the same scope it is used. Fixes #10570 Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 4b0aa92 commit 7597939

File tree

1 file changed

+11
-8
lines changed
  • subsys/bluetooth/shell

1 file changed

+11
-8
lines changed

subsys/bluetooth/shell/bt.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -855,16 +855,19 @@ static int cmd_directed_adv(const struct shell *shell,
855855
return err;
856856
}
857857

858-
if (argc > 3) {
859-
if (!strcmp(argv[3], "low")) {
860-
param = BT_LE_ADV_CONN_DIR_LOW_DUTY;
861-
} else {
862-
shell_help_print(shell, NULL, 0);
863-
/* shell_cmd_precheck returns 1 when help is printed */
864-
return 1;
865-
}
858+
if (argc == 3) {
859+
goto connect;
866860
}
867861

862+
if (strcmp(argv[3], "low")) {
863+
shell_help_print(shell, NULL, 0);
864+
/* shell_cmd_precheck returns 1 when help is printed */
865+
return 1;
866+
}
867+
868+
param = BT_LE_ADV_CONN_DIR_LOW_DUTY;
869+
870+
connect:
868871
conn = bt_conn_create_slave_le(&addr, param);
869872
if (!conn) {
870873
error(shell, "Failed to start directed advertising");

0 commit comments

Comments
 (0)