Bluetooth: Use `bt_addr_eq`
Refactor. Using `bt_addr_eq` instead of `bt_addr_cmp`.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
diff --git a/drivers/bluetooth/hci/ipm_stm32wb.c b/drivers/bluetooth/hci/ipm_stm32wb.c
index 48f55b5..9ee261a 100644
--- a/drivers/bluetooth/hci/ipm_stm32wb.c
+++ b/drivers/bluetooth/hci/ipm_stm32wb.c
@@ -147,7 +147,7 @@
struct bt_hci_evt_le_enh_conn_complete *evt =
(void *)((uint8_t *)mev + (sizeof(*mev)));
- if (!bt_addr_cmp(&evt->peer_addr.a, BT_ADDR_NONE)) {
+ if (bt_addr_eq(&evt->peer_addr.a, BT_ADDR_NONE)) {
LOG_WRN("Invalid peer addr %s", bt_addr_le_str(&evt->peer_addr));
bt_addr_copy(&evt->peer_addr.a, &evt->peer_rpa);
evt->peer_addr.type = BT_ADDR_LE_RANDOM;
diff --git a/subsys/bluetooth/controller/ll_sw/ull_filter.c b/subsys/bluetooth/controller/ll_sw/ull_filter.c
index 3be6f80..27a9799 100644
--- a/subsys/bluetooth/controller/ll_sw/ull_filter.c
+++ b/subsys/bluetooth/controller/ll_sw/ull_filter.c
@@ -1493,7 +1493,7 @@
idx = twork->idx;
search_rpa = &(twork->rpa);
- if (rl[idx].taken && !bt_addr_cmp(&(rl[idx].target_rpa), search_rpa)) {
+ if (rl[idx].taken && bt_addr_eq(&(rl[idx].target_rpa), search_rpa)) {
j = idx;
} else {
/* No match - so not in list Need to see if we can resolve */
@@ -1618,7 +1618,7 @@
{
for (uint8_t i = 0; i < CONFIG_BT_CTLR_RPA_CACHE_SIZE; i++) {
if (prpa_cache[i].taken &&
- !bt_addr_cmp(&(prpa_cache[i].rpa), rpa)) {
+ bt_addr_eq(&(prpa_cache[i].rpa), rpa)) {
return i;
}
}
diff --git a/subsys/bluetooth/host/adv.c b/subsys/bluetooth/host/adv.c
index 619a917..771709b 100644
--- a/subsys/bluetooth/host/adv.c
+++ b/subsys/bluetooth/host/adv.c
@@ -2205,8 +2205,7 @@
!atomic_test_bit(adv->flags, BT_ADV_USE_IDENTITY)) {
/* Set Responder address unless already set */
conn->le.resp_addr.type = BT_ADDR_LE_RANDOM;
- if (bt_addr_cmp(&conn->le.resp_addr.a,
- BT_ADDR_ANY) == 0) {
+ if (bt_addr_eq(&conn->le.resp_addr.a, BT_ADDR_ANY)) {
bt_addr_copy(&conn->le.resp_addr.a,
&adv->random_addr.a);
}
diff --git a/subsys/bluetooth/host/br.c b/subsys/bluetooth/host/br.c
index 3afeae1..1d48516 100644
--- a/subsys/bluetooth/host/br.c
+++ b/subsys/bluetooth/host/br.c
@@ -428,7 +428,7 @@
/* check if already present in results */
for (i = 0; i < discovery_results_count; i++) {
- if (!bt_addr_cmp(addr, &discovery_results[i].addr)) {
+ if (bt_addr_eq(addr, &discovery_results[i].addr)) {
return &discovery_results[i];
}
}
diff --git a/subsys/bluetooth/host/conn.c b/subsys/bluetooth/host/conn.c
index 152c3aa..ff1c5e5 100644
--- a/subsys/bluetooth/host/conn.c
+++ b/subsys/bluetooth/host/conn.c
@@ -1993,7 +1993,7 @@
continue;
}
- if (bt_addr_cmp(peer, &conn->sco.acl->br.dst) != 0) {
+ if (!bt_addr_eq(peer, &conn->sco.acl->br.dst)) {
bt_conn_unref(conn);
continue;
}
@@ -2020,7 +2020,7 @@
continue;
}
- if (bt_addr_cmp(peer, &conn->br.dst) != 0) {
+ if (!bt_addr_eq(peer, &conn->br.dst)) {
bt_conn_unref(conn);
continue;
}
diff --git a/subsys/bluetooth/host/hci_core.c b/subsys/bluetooth/host/hci_core.c
index cbc0208..95cfecf 100644
--- a/subsys/bluetooth/host/hci_core.c
+++ b/subsys/bluetooth/host/hci_core.c
@@ -1358,8 +1358,7 @@
if (IS_ENABLED(CONFIG_BT_PRIVACY) &&
!atomic_test_bit(adv->flags, BT_ADV_USE_IDENTITY)) {
conn->le.resp_addr.type = BT_ADDR_LE_RANDOM;
- if (bt_addr_cmp(&evt->local_rpa,
- BT_ADDR_ANY) != 0) {
+ if (!bt_addr_eq(&evt->local_rpa, BT_ADDR_ANY)) {
bt_addr_copy(&conn->le.resp_addr.a,
&evt->local_rpa);
} else {
@@ -1404,7 +1403,7 @@
if (IS_ENABLED(CONFIG_BT_PRIVACY)) {
conn->le.init_addr.type = BT_ADDR_LE_RANDOM;
- if (bt_addr_cmp(&evt->local_rpa, BT_ADDR_ANY) != 0) {
+ if (!bt_addr_eq(&evt->local_rpa, BT_ADDR_ANY)) {
bt_addr_copy(&conn->le.init_addr.a,
&evt->local_rpa);
} else {
diff --git a/subsys/bluetooth/host/id.c b/subsys/bluetooth/host/id.c
index 98c06ec..49bbf47 100644
--- a/subsys/bluetooth/host/id.c
+++ b/subsys/bluetooth/host/id.c
@@ -128,7 +128,7 @@
LOG_DBG("%s", bt_addr_str(addr));
/* Do nothing if we already have the right address */
- if (!bt_addr_cmp(addr, &bt_dev.random_addr.a)) {
+ if (bt_addr_eq(addr, &bt_dev.random_addr.a)) {
return 0;
}
@@ -1434,8 +1434,8 @@
rp = (void *)rsp->data;
- if (!bt_addr_cmp(&rp->bdaddr, BT_ADDR_ANY) ||
- !bt_addr_cmp(&rp->bdaddr, BT_ADDR_NONE)) {
+ if (bt_addr_eq(&rp->bdaddr, BT_ADDR_ANY) ||
+ bt_addr_eq(&rp->bdaddr, BT_ADDR_NONE)) {
LOG_DBG("Controller has no public address");
net_buf_unref(rsp);
return 0U;
diff --git a/subsys/bluetooth/host/keys.c b/subsys/bluetooth/host/keys.c
index 632d67f..b254631 100644
--- a/subsys/bluetooth/host/keys.c
+++ b/subsys/bluetooth/host/keys.c
@@ -244,7 +244,7 @@
}
if (key_pool[i].id == id &&
- !bt_addr_cmp(&addr->a, &key_pool[i].irk.rpa)) {
+ bt_addr_eq(&addr->a, &key_pool[i].irk.rpa)) {
LOG_DBG("cached RPA %s for %s", bt_addr_str(&key_pool[i].irk.rpa),
bt_addr_le_str(&key_pool[i].addr));
return &key_pool[i];
diff --git a/subsys/bluetooth/host/keys_br.c b/subsys/bluetooth/host/keys_br.c
index ee32f26..afccc1b 100644
--- a/subsys/bluetooth/host/keys_br.c
+++ b/subsys/bluetooth/host/keys_br.c
@@ -43,7 +43,7 @@
for (i = 0; i < ARRAY_SIZE(key_pool); i++) {
key = &key_pool[i];
- if (!bt_addr_cmp(&key->addr, addr)) {
+ if (bt_addr_eq(&key->addr, addr)) {
return key;
}
}
diff --git a/tests/bluetooth/host/keys/bt_keys_find_irk/src/main.c b/tests/bluetooth/host/keys/bt_keys_find_irk/src/main.c
index 8f9793d..1c46722 100644
--- a/tests/bluetooth/host/keys/bt_keys_find_irk/src/main.c
+++ b/tests/bluetooth/host/keys/bt_keys_find_irk/src/main.c
@@ -68,7 +68,7 @@
static bool bt_rpa_irk_matches_custom_fake(const uint8_t irk[16], const bt_addr_t *addr)
{
- if (irk[0] != (params_it) && !bt_addr_cmp(¤t_params_vector->addr->a, addr)) {
+ if (irk[0] != (params_it) && bt_addr_eq(¤t_params_vector->addr->a, addr)) {
return false;
}