Skip to content

Commit 21e5dcb

Browse files
alwa-nordicjhedberg
authored andcommitted
Bluetooth: Replace 'bt_addr_le_cmp(x) == 0' with 'bt_addr_le_eq(x)'
These should be equivalent. The '_eq'-form is more readable. Signed-off-by: Aleksander Wasaznik <[email protected]>
1 parent 9db3fa8 commit 21e5dcb

File tree

9 files changed

+18
-26
lines changed

9 files changed

+18
-26
lines changed

subsys/bluetooth/audio/bass.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ static struct bass_recv_state_internal *bass_lookup_pa_sync(struct bt_le_per_adv
338338
static struct bass_recv_state_internal *bass_lookup_addr(const bt_addr_le_t *addr)
339339
{
340340
for (int i = 0; i < ARRAY_SIZE(bass_inst.recv_states); i++) {
341-
if (bt_addr_le_cmp(&bass_inst.recv_states[i].state.addr, addr) == 0) {
341+
if (bt_addr_le_eq(&bass_inst.recv_states[i].state.addr, addr)) {
342342
return &bass_inst.recv_states[i];
343343
}
344344
}

subsys/bluetooth/audio/csis.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ static void notify_client(struct bt_conn *conn, void *data)
8282
pend_notify = &csis->srv.pend_notify[i];
8383

8484
if (pend_notify->pending &&
85-
bt_addr_le_cmp(bt_conn_get_dst(conn),
86-
&pend_notify->addr) == 0) {
85+
bt_addr_le_eq(bt_conn_get_dst(conn), &pend_notify->addr)) {
8786
pend_notify->pending = false;
8887
break;
8988
}
@@ -108,8 +107,7 @@ static void notify_clients(struct bt_csis *csis,
108107

109108
if (pend_notify->active) {
110109
if (excluded_client != NULL &&
111-
bt_addr_le_cmp(bt_conn_get_dst(excluded_client),
112-
&pend_notify->addr) == 0) {
110+
bt_addr_le_eq(bt_conn_get_dst(excluded_client), &pend_notify->addr)) {
113111
continue;
114112
}
115113

@@ -453,8 +451,7 @@ static void csis_security_changed(struct bt_conn *conn, bt_security_t level,
453451
pend_notify = &csis->srv.pend_notify[j];
454452

455453
if (pend_notify->pending &&
456-
bt_addr_le_cmp(bt_conn_get_dst(conn),
457-
&pend_notify->addr) == 0) {
454+
bt_addr_le_eq(bt_conn_get_dst(conn), &pend_notify->addr)) {
458455
notify_lock_value(csis, conn);
459456
pend_notify->pending = false;
460457
break;
@@ -487,8 +484,7 @@ static void handle_csis_disconnect(struct bt_csis *csis, struct bt_conn *conn)
487484

488485
pend_notify = &csis->srv.pend_notify[i];
489486

490-
if (bt_addr_le_cmp(bt_conn_get_dst(conn),
491-
&pend_notify->addr) == 0) {
487+
if (bt_addr_le_eq(bt_conn_get_dst(conn), &pend_notify->addr)) {
492488
(void)memset(pend_notify, 0, sizeof(*pend_notify));
493489
break;
494490
}
@@ -515,8 +511,7 @@ static void handle_csis_auth_complete(struct bt_csis *csis,
515511
pend_notify = &csis->srv.pend_notify[i];
516512

517513
if (pend_notify->active &&
518-
bt_addr_le_cmp(bt_conn_get_dst(conn),
519-
&pend_notify->addr) == 0) {
514+
bt_addr_le_eq(bt_conn_get_dst(conn), &pend_notify->addr)) {
520515
#if IS_ENABLED(CONFIG_BT_KEYS_OVERWRITE_OLDEST)
521516
pend_notify->age = csis->srv.age_counter++;
522517
#endif /* CONFIG_BT_KEYS_OVERWRITE_OLDEST */
@@ -601,7 +596,7 @@ static void csis_bond_deleted(uint8_t id, const bt_addr_le_t *peer)
601596
pend_notify = &csis->srv.pend_notify[j];
602597

603598
if (pend_notify->active &&
604-
bt_addr_le_cmp(peer, &pend_notify->addr) == 0) {
599+
bt_addr_le_eq(peer, &pend_notify->addr)) {
605600
(void)memset(pend_notify, 0,
606601
sizeof(*pend_notify));
607602
break;

subsys/bluetooth/host/conn.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2186,10 +2186,10 @@ bool bt_conn_is_peer_addr_le(const struct bt_conn *conn, uint8_t id,
21862186

21872187
/* Check against initial connection address */
21882188
if (conn->role == BT_HCI_ROLE_CENTRAL) {
2189-
return bt_addr_le_cmp(peer, &conn->le.resp_addr) == 0;
2189+
return bt_addr_le_eq(peer, &conn->le.resp_addr);
21902190
}
21912191

2192-
return bt_addr_le_cmp(peer, &conn->le.init_addr) == 0;
2192+
return bt_addr_le_eq(peer, &conn->le.init_addr);
21932193
}
21942194

21952195
struct bt_conn *bt_conn_lookup_addr_le(uint8_t id, const bt_addr_le_t *peer)

subsys/bluetooth/host/gatt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ static uint8_t convert_to_id_on_match(const struct bt_gatt_attr *attr,
991991
* same as the device's private address
992992
*/
993993
for (size_t i = 0; i < ARRAY_SIZE(ccc->cfg); i++) {
994-
if (bt_addr_le_cmp(&ccc->cfg[i].peer, match->private_addr) == 0) {
994+
if (bt_addr_le_eq(&ccc->cfg[i].peer, match->private_addr)) {
995995
bt_addr_le_copy(&ccc->cfg[i].peer, match->id_addr);
996996
}
997997
}

subsys/bluetooth/host/scan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static bool fragmented_advertisers_equal(const struct fragmented_advertiser *a,
4949
const bt_addr_le_t *addr, uint8_t sid)
5050
{
5151
/* Two advertisers are equal if they are the same adv set from the same device */
52-
return a->sid == sid && bt_addr_le_cmp(&a->addr, addr) == 0;
52+
return a->sid == sid && bt_addr_le_eq(&a->addr, addr);
5353
}
5454

5555
/* Sets the address and sid of the advertiser to be reassembled. */

subsys/bluetooth/shell/bass_client.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ static void bass_client_recv_state_cb(struct bt_conn *conn, int err,
101101
/* Lookup matching PA sync */
102102
for (int i = 0; i < ARRAY_SIZE(per_adv_syncs); i++) {
103103
if (per_adv_syncs[i] &&
104-
bt_addr_le_cmp(&per_adv_syncs[i]->addr,
105-
&state->addr) == 0) {
104+
bt_addr_le_eq(&per_adv_syncs[i]->addr, &state->addr)) {
106105
per_adv_sync = per_adv_syncs[i];
107106
break;
108107
}
@@ -141,8 +140,7 @@ static void bass_client_recv_state_cb(struct bt_conn *conn, int err,
141140
return;
142141
}
143142

144-
if (bt_addr_le_cmp(&oob_local.addr,
145-
&state->addr) == 0) {
143+
if (bt_addr_le_eq(&oob_local.addr, &state->addr)) {
146144
ext_adv = adv_sets[i];
147145
break;
148146
}

subsys/bluetooth/shell/csis_client.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static struct bt_csis_client_set_member *locked_members[CONFIG_BT_MAX_CONN];
3232
static bool is_discovered(const bt_addr_le_t *addr)
3333
{
3434
for (int i = 0; i < members_found; i++) {
35-
if (bt_addr_le_cmp(addr, &addr_found[i]) == 0) {
35+
if (bt_addr_le_eq(addr, &addr_found[i])) {
3636
return true;
3737
}
3838
}
@@ -65,8 +65,7 @@ static void connected_cb(struct bt_conn *conn, uint8_t err)
6565
}
6666

6767
for (uint8_t i = 0; i < members_found; i++) {
68-
if (bt_addr_le_cmp(bt_conn_get_dst(conn),
69-
&addr_found[i]) == 0) {
68+
if (bt_addr_le_eq(bt_conn_get_dst(conn), &addr_found[i])) {
7069
set_members[i].conn = conn;
7170
shell_print(ctx_shell, "Member[%u] connected", i);
7271
return;

tests/bluetooth/bsim_bt/bsim_test_audio/src/csis_client_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static bool csis_client_oap_cb(const struct bt_csis_client_set_info *set_info,
132132
static bool is_discovered(const bt_addr_le_t *addr)
133133
{
134134
for (int i = 0; i < members_found; i++) {
135-
if (bt_addr_le_cmp(addr, &addr_found[i]) == 0) {
135+
if (bt_addr_le_eq(addr, &addr_found[i])) {
136136
return true;
137137
}
138138
}

tests/bluetooth/tester/src/gap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static uint8_t read_car_cb(struct bt_conn *conn, uint8_t err,
8484
bt_conn_get_info(conn, &info);
8585

8686
for (int i = 0; i < CONFIG_BT_MAX_PAIRED; i++) {
87-
if (bt_addr_le_cmp(info.le.dst, &cars[i].addr) == 0) {
87+
if (bt_addr_le_eq(info.le.dst, &cars[i].addr)) {
8888
cars[i].supported = supported;
8989
break;
9090
}
@@ -590,7 +590,7 @@ static void start_directed_advertising(const uint8_t *data, uint16_t len)
590590
#if defined(CONFIG_BT_PRIVACY)
591591
/* check if peer supports Central Address Resolution */
592592
for (int i = 0; i < CONFIG_BT_MAX_PAIRED; i++) {
593-
if (bt_addr_le_cmp(peer, &cars[i].addr) == 0) {
593+
if (bt_addr_le_eq(peer, &cars[i].addr)) {
594594
if (cars[i].supported) {
595595
adv_param.options |= BT_LE_ADV_OPT_DIR_ADDR_RPA;
596596
}

0 commit comments

Comments
 (0)