Skip to content

Commit 3b33ba2

Browse files
committed
Bluetooth: shell: Avoid reusing the same label
To avoid hitting the following violation: Violation to rule 5.7 (Tag name should be unique) Replace the use of "shell" in the shell as an instance of a pointer to const struct shell. Signed-off-by: Carles Cufi <[email protected]>
1 parent f1dff28 commit 3b33ba2

File tree

11 files changed

+498
-498
lines changed

11 files changed

+498
-498
lines changed

subsys/bluetooth/shell/bredr.c

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ NET_BUF_POOL_FIXED_DEFINE(data_pool, 1, DATA_BREDR_MTU, NULL);
4444
NET_BUF_POOL_FIXED_DEFINE(sdp_client_pool, CONFIG_BT_MAX_CONN,
4545
SDP_CLIENT_USER_BUF_LEN, NULL);
4646

47-
static int cmd_auth_pincode(const struct shell *shell,
47+
static int cmd_auth_pincode(const struct shell *sh,
4848
size_t argc, char *argv[])
4949
{
5050
struct bt_conn *conn;
@@ -59,41 +59,41 @@ static int cmd_auth_pincode(const struct shell *shell,
5959
}
6060

6161
if (!conn) {
62-
shell_print(shell, "Not connected");
62+
shell_print(sh, "Not connected");
6363
return 0;
6464
}
6565

6666
if (strlen(argv[1]) > max) {
67-
shell_print(shell, "PIN code value invalid - enter max %u "
67+
shell_print(sh, "PIN code value invalid - enter max %u "
6868
"digits", max);
6969
return 0;
7070
}
7171

72-
shell_print(shell, "PIN code \"%s\" applied", argv[1]);
72+
shell_print(sh, "PIN code \"%s\" applied", argv[1]);
7373

7474
bt_conn_auth_pincode_entry(conn, argv[1]);
7575

7676
return 0;
7777
}
7878

79-
static int cmd_connect(const struct shell *shell, size_t argc, char *argv[])
79+
static int cmd_connect(const struct shell *sh, size_t argc, char *argv[])
8080
{
8181
struct bt_conn *conn;
8282
bt_addr_t addr;
8383
int err;
8484

8585
err = bt_addr_from_str(argv[1], &addr);
8686
if (err) {
87-
shell_print(shell, "Invalid peer address (err %d)", err);
87+
shell_print(sh, "Invalid peer address (err %d)", err);
8888
return -ENOEXEC;
8989
}
9090

9191
conn = bt_conn_create_br(&addr, BT_BR_CONN_PARAM_DEFAULT);
9292
if (!conn) {
93-
shell_print(shell, "Connection failed");
93+
shell_print(sh, "Connection failed");
9494
} else {
9595

96-
shell_print(shell, "Connection pending");
96+
shell_print(sh, "Connection pending");
9797

9898
/* unref connection obj in advance as app user */
9999
bt_conn_unref(conn);
@@ -164,7 +164,7 @@ static void br_discovery_complete(struct bt_br_discovery_result *results,
164164
}
165165
}
166166

167-
static int cmd_discovery(const struct shell *shell, size_t argc, char *argv[])
167+
static int cmd_discovery(const struct shell *sh, size_t argc, char *argv[])
168168
{
169169
const char *action;
170170

@@ -186,20 +186,20 @@ static int cmd_discovery(const struct shell *shell, size_t argc, char *argv[])
186186
if (bt_br_discovery_start(&param, br_discovery_results,
187187
ARRAY_SIZE(br_discovery_results),
188188
br_discovery_complete) < 0) {
189-
shell_print(shell, "Failed to start discovery");
189+
shell_print(sh, "Failed to start discovery");
190190
return 0;
191191
}
192192

193-
shell_print(shell, "Discovery started");
193+
shell_print(sh, "Discovery started");
194194
} else if (!strcmp(action, "off")) {
195195
if (bt_br_discovery_stop()) {
196-
shell_print(shell, "Failed to stop discovery");
196+
shell_print(sh, "Failed to stop discovery");
197197
return 0;
198198
}
199199

200-
shell_print(shell, "Discovery stopped");
200+
shell_print(sh, "Discovery stopped");
201201
} else {
202-
shell_help(shell);
202+
shell_help(sh);
203203
}
204204

205205
return 0;
@@ -261,28 +261,28 @@ static struct bt_l2cap_server br_server = {
261261
.accept = l2cap_accept,
262262
};
263263

264-
static int cmd_l2cap_register(const struct shell *shell,
264+
static int cmd_l2cap_register(const struct shell *sh,
265265
size_t argc, char *argv[])
266266
{
267267
if (br_server.psm) {
268-
shell_print(shell, "Already registered");
268+
shell_print(sh, "Already registered");
269269
return 0;
270270
}
271271

272272
br_server.psm = strtoul(argv[1], NULL, 16);
273273

274274
if (bt_l2cap_br_server_register(&br_server) < 0) {
275-
shell_error(shell, "Unable to register psm");
275+
shell_error(sh, "Unable to register psm");
276276
br_server.psm = 0U;
277277
return -ENOEXEC;
278278
} else {
279-
shell_print(shell, "L2CAP psm %u registered", br_server.psm);
279+
shell_print(sh, "L2CAP psm %u registered", br_server.psm);
280280
}
281281

282282
return 0;
283283
}
284284

285-
static int cmd_discoverable(const struct shell *shell,
285+
static int cmd_discoverable(const struct shell *sh,
286286
size_t argc, char *argv[])
287287
{
288288
int err;
@@ -295,22 +295,22 @@ static int cmd_discoverable(const struct shell *shell,
295295
} else if (!strcmp(action, "off")) {
296296
err = bt_br_set_discoverable(false);
297297
} else {
298-
shell_help(shell);
298+
shell_help(sh);
299299
return 0;
300300
}
301301

302302
if (err) {
303-
shell_print(shell, "BR/EDR set/reset discoverable failed "
303+
shell_print(sh, "BR/EDR set/reset discoverable failed "
304304
"(err %d)", err);
305305
return -ENOEXEC;
306306
} else {
307-
shell_print(shell, "BR/EDR set/reset discoverable done");
307+
shell_print(sh, "BR/EDR set/reset discoverable done");
308308
}
309309

310310
return 0;
311311
}
312312

313-
static int cmd_connectable(const struct shell *shell,
313+
static int cmd_connectable(const struct shell *sh,
314314
size_t argc, char *argv[])
315315
{
316316
int err;
@@ -323,37 +323,37 @@ static int cmd_connectable(const struct shell *shell,
323323
} else if (!strcmp(action, "off")) {
324324
err = bt_br_set_connectable(false);
325325
} else {
326-
shell_help(shell);
326+
shell_help(sh);
327327
return 0;
328328
}
329329

330330
if (err) {
331-
shell_print(shell, "BR/EDR set/rest connectable failed "
331+
shell_print(sh, "BR/EDR set/rest connectable failed "
332332
"(err %d)", err);
333333
return -ENOEXEC;
334334
} else {
335-
shell_print(shell, "BR/EDR set/reset connectable done");
335+
shell_print(sh, "BR/EDR set/reset connectable done");
336336
}
337337

338338
return 0;
339339
}
340340

341-
static int cmd_oob(const struct shell *shell, size_t argc, char *argv[])
341+
static int cmd_oob(const struct shell *sh, size_t argc, char *argv[])
342342
{
343343
char addr[BT_ADDR_STR_LEN];
344344
struct bt_br_oob oob;
345345
int err;
346346

347347
err = bt_br_oob_get_local(&oob);
348348
if (err) {
349-
shell_print(shell, "BR/EDR OOB data failed");
349+
shell_print(sh, "BR/EDR OOB data failed");
350350
return -ENOEXEC;
351351
}
352352

353353
bt_addr_to_str(&oob.addr, addr, sizeof(addr));
354354

355-
shell_print(shell, "BR/EDR OOB data:");
356-
shell_print(shell, " addr %s", addr);
355+
shell_print(sh, "BR/EDR OOB data:");
356+
shell_print(sh, " addr %s", addr);
357357
return 0;
358358
}
359359

@@ -495,14 +495,14 @@ static struct bt_sdp_discover_params discov_a2src = {
495495

496496
static struct bt_sdp_discover_params discov;
497497

498-
static int cmd_sdp_find_record(const struct shell *shell,
498+
static int cmd_sdp_find_record(const struct shell *sh,
499499
size_t argc, char *argv[])
500500
{
501501
int res;
502502
const char *action;
503503

504504
if (!default_conn) {
505-
shell_print(shell, "Not connected");
505+
shell_print(sh, "Not connected");
506506
return 0;
507507
}
508508

@@ -513,18 +513,18 @@ static int cmd_sdp_find_record(const struct shell *shell,
513513
} else if (!strcmp(action, "A2SRC")) {
514514
discov = discov_a2src;
515515
} else {
516-
shell_help(shell);
516+
shell_help(sh);
517517
return 0;
518518
}
519519

520-
shell_print(shell, "SDP UUID \'%s\' gets applied", action);
520+
shell_print(sh, "SDP UUID \'%s\' gets applied", action);
521521

522522
res = bt_sdp_discover(default_conn, &discov);
523523
if (res) {
524-
shell_error(shell, "SDP discovery failed: result %d", res);
524+
shell_error(sh, "SDP discovery failed: result %d", res);
525525
return -ENOEXEC;
526526
} else {
527-
shell_print(shell, "SDP discovery started");
527+
shell_print(sh, "SDP discovery started");
528528
}
529529

530530
return 0;
@@ -547,15 +547,15 @@ SHELL_STATIC_SUBCMD_SET_CREATE(br_cmds,
547547
SHELL_SUBCMD_SET_END
548548
);
549549

550-
static int cmd_br(const struct shell *shell, size_t argc, char **argv)
550+
static int cmd_br(const struct shell *sh, size_t argc, char **argv)
551551
{
552552
if (argc == 1) {
553-
shell_help(shell);
553+
shell_help(sh);
554554
/* shell returns 1 when help is printed */
555555
return 1;
556556
}
557557

558-
shell_error(shell, "%s unknown parameter: %s", argv[0], argv[1]);
558+
shell_error(sh, "%s unknown parameter: %s", argv[0], argv[1]);
559559

560560
return -ENOEXEC;
561561
}

0 commit comments

Comments
 (0)