Skip to content

Commit ea55818

Browse files
alwa-nordicjhedberg
authored andcommitted
Bluetooth: Replace bt_addr_le_cmp in bool context with !bt_addr_le_eq
These should be equivalent. The new form is more readable. Signed-off-by: Aleksander Wasaznik <[email protected]>
1 parent 21e5dcb commit ea55818

File tree

7 files changed

+14
-14
lines changed

7 files changed

+14
-14
lines changed

subsys/bluetooth/host/gatt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1430,7 +1430,7 @@ static void gatt_unregister_ccc(struct _bt_gatt_ccc *ccc)
14301430
for (size_t i = 0; i < ARRAY_SIZE(ccc->cfg); i++) {
14311431
struct bt_gatt_ccc_cfg *cfg = &ccc->cfg[i];
14321432

1433-
if (bt_addr_le_cmp(&cfg->peer, BT_ADDR_LE_ANY)) {
1433+
if (!bt_addr_le_eq(&cfg->peer, BT_ADDR_LE_ANY)) {
14341434
struct bt_conn *conn;
14351435
bool store = true;
14361436

subsys/bluetooth/host/hci_core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ int bt_le_create_conn_ext(const struct bt_conn *conn)
580580
} else {
581581
const bt_addr_le_t *peer_addr = &conn->le.dst;
582582

583-
if (bt_addr_le_cmp(&conn->le.resp_addr, BT_ADDR_LE_ANY)) {
583+
if (!bt_addr_le_eq(&conn->le.resp_addr, BT_ADDR_LE_ANY)) {
584584
/* Host resolving is used, use the RPA directly. */
585585
peer_addr = &conn->le.resp_addr;
586586
BT_DBG("Using resp_addr %s", bt_addr_le_str(peer_addr));
@@ -653,7 +653,7 @@ static int bt_le_create_conn_legacy(const struct bt_conn *conn)
653653
} else {
654654
const bt_addr_le_t *peer_addr = &conn->le.dst;
655655

656-
if (bt_addr_le_cmp(&conn->le.resp_addr, BT_ADDR_LE_ANY)) {
656+
if (!bt_addr_le_eq(&conn->le.resp_addr, BT_ADDR_LE_ANY)) {
657657
/* Host resolving is used, use the RPA directly. */
658658
peer_addr = &conn->le.resp_addr;
659659
BT_DBG("Using resp_addr %s", bt_addr_le_str(peer_addr));

subsys/bluetooth/host/id.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,7 @@ static int id_find(const bt_addr_le_t *addr)
10651065

10661066
static int id_create(uint8_t id, bt_addr_le_t *addr, uint8_t *irk)
10671067
{
1068-
if (addr && bt_addr_le_cmp(addr, BT_ADDR_LE_ANY)) {
1068+
if (addr && !bt_addr_le_eq(addr, BT_ADDR_LE_ANY)) {
10691069
bt_addr_le_copy(&bt_dev.id_addr[id], addr);
10701070
} else {
10711071
bt_addr_le_t new_addr;
@@ -1123,7 +1123,7 @@ int bt_id_create(bt_addr_le_t *addr, uint8_t *irk)
11231123
{
11241124
int new_id, err;
11251125

1126-
if (addr && bt_addr_le_cmp(addr, BT_ADDR_LE_ANY)) {
1126+
if (addr && !bt_addr_le_eq(addr, BT_ADDR_LE_ANY)) {
11271127
if (addr->type != BT_ADDR_LE_RANDOM ||
11281128
!BT_ADDR_IS_STATIC(&addr->a)) {
11291129
BT_ERR("Only static random identity address supported");
@@ -1147,7 +1147,7 @@ int bt_id_create(bt_addr_le_t *addr, uint8_t *irk)
11471147
if (!atomic_test_bit(bt_dev.flags, BT_DEV_ENABLE)) {
11481148
uint8_t zero_irk[16] = { 0 };
11491149

1150-
if (!(addr && bt_addr_le_cmp(addr, BT_ADDR_LE_ANY))) {
1150+
if (!(addr && !bt_addr_le_eq(addr, BT_ADDR_LE_ANY))) {
11511151
return -EINVAL;
11521152
}
11531153

@@ -1170,7 +1170,7 @@ int bt_id_reset(uint8_t id, bt_addr_le_t *addr, uint8_t *irk)
11701170
{
11711171
int err;
11721172

1173-
if (addr && bt_addr_le_cmp(addr, BT_ADDR_LE_ANY)) {
1173+
if (addr && !bt_addr_le_eq(addr, BT_ADDR_LE_ANY)) {
11741174
if (addr->type != BT_ADDR_LE_RANDOM ||
11751175
!BT_ADDR_IS_STATIC(&addr->a)) {
11761176
BT_ERR("Only static random identity address supported");
@@ -1203,7 +1203,7 @@ int bt_id_reset(uint8_t id, bt_addr_le_t *addr, uint8_t *irk)
12031203
}
12041204

12051205
if (IS_ENABLED(CONFIG_BT_CONN) &&
1206-
bt_addr_le_cmp(&bt_dev.id_addr[id], BT_ADDR_LE_ANY)) {
1206+
!bt_addr_le_eq(&bt_dev.id_addr[id], BT_ADDR_LE_ANY)) {
12071207
err = bt_unpair(id, NULL);
12081208
if (err) {
12091209
return err;

subsys/bluetooth/host/scan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ void bt_hci_le_per_adv_sync_established(struct net_buf *buf)
892892
(!atomic_test_bit(pending_per_adv_sync->flags,
893893
BT_PER_ADV_SYNC_SYNCING_USE_LIST) &&
894894
((pending_per_adv_sync->sid != evt->sid) ||
895-
bt_addr_le_cmp(&pending_per_adv_sync->addr, &evt->adv_addr)))) {
895+
!bt_addr_le_eq(&pending_per_adv_sync->addr, &evt->adv_addr)))) {
896896
BT_ERR("Unexpected per adv sync established event");
897897
/* Request terminate of pending periodic advertising in controller */
898898
per_adv_sync_terminate(sys_le16_to_cpu(evt->handle));

subsys/bluetooth/host/smp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1522,7 +1522,7 @@ static uint8_t smp_br_ident_addr_info(struct bt_smp_br *smp,
15221522
bt_addr_copy(&addr.a, &conn->br.dst);
15231523
addr.type = BT_ADDR_LE_PUBLIC;
15241524

1525-
if (bt_addr_le_cmp(&addr, &req->addr)) {
1525+
if (!bt_addr_le_eq(&addr, &req->addr)) {
15261526
return BT_SMP_ERR_UNSPECIFIED;
15271527
}
15281528

subsys/bluetooth/shell/bt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2983,7 +2983,7 @@ static void auth_pairing_oob_data_request(struct bt_conn *conn,
29832983
: NULL;
29842984

29852985
if (oobd_remote &&
2986-
bt_addr_le_cmp(info.le.remote, &oob_remote.addr)) {
2986+
!bt_addr_le_eq(info.le.remote, &oob_remote.addr)) {
29872987
bt_addr_le_to_str(info.le.remote, addr, sizeof(addr));
29882988
shell_print(ctx_shell,
29892989
"No OOB data available for remote %s",
@@ -2993,7 +2993,7 @@ static void auth_pairing_oob_data_request(struct bt_conn *conn,
29932993
}
29942994

29952995
if (oobd_local &&
2996-
bt_addr_le_cmp(info.le.local, &oob_local.addr)) {
2996+
!bt_addr_le_eq(info.le.local, &oob_local.addr)) {
29972997
bt_addr_le_to_str(info.le.local, addr, sizeof(addr));
29982998
shell_print(ctx_shell,
29992999
"No OOB data available for local %s",

tests/bluetooth/tester/src/gap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ static void oob_data_request(struct bt_conn *conn,
375375
}
376376

377377
if (oobd_local &&
378-
bt_addr_le_cmp(info.le.local, &oob_sc_local.addr)) {
378+
!bt_addr_le_eq(info.le.local, &oob_sc_local.addr)) {
379379
bt_addr_le_to_str(info.le.local, addr, sizeof(addr));
380380
LOG_DBG("No OOB data available for local %s",
381381
addr);
@@ -725,7 +725,7 @@ static void device_found(const bt_addr_le_t *addr, int8_t rssi, uint8_t evtype,
725725
* Advertisement, but if not if send stored event and ignore
726726
* this one
727727
*/
728-
if (bt_addr_le_cmp(addr, &a)) {
728+
if (!bt_addr_le_eq(addr, &a)) {
729729
LOG_INF("Address does not match, skipping");
730730
goto done;
731731
}

0 commit comments

Comments
 (0)