From a65109990d64382ba74912701b63e808bef54239 Mon Sep 17 00:00:00 2001 From: Roman Sukhorukov Date: Sun, 11 Aug 2024 14:19:04 +0300 Subject: [PATCH] Code style changes --- nimble/host/src/ble_att_svr.c | 18 +++++------------- nimble/host/src/ble_gatts.c | 9 +++------ nimble/host/src/ble_hs_hci_evt.c | 22 ++++++++++------------ 3 files changed, 18 insertions(+), 31 deletions(-) diff --git a/nimble/host/src/ble_att_svr.c b/nimble/host/src/ble_att_svr.c index 145318f09d..17f3aa6d43 100644 --- a/nimble/host/src/ble_att_svr.c +++ b/nimble/host/src/ble_att_svr.c @@ -157,11 +157,7 @@ struct ble_att_svr_entry * ble_att_svr_find_by_handle(uint16_t handle_id) { struct ble_att_svr_entry *entry; - - for (entry = STAILQ_FIRST(&ble_att_svr_list); - entry != NULL; - entry = STAILQ_NEXT(entry, ha_next)) { - + STAILQ_FOREACH(entry, &ble_att_svr_list, ha_next) { if (entry->ha_handle_id == handle_id) { return entry; } @@ -1449,16 +1445,12 @@ ble_att_svr_rx_read(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) return BLE_HS_ENOTSUP; #endif - struct ble_att_read_req *req; - struct os_mbuf *txom; - uint16_t err_handle; - uint8_t att_err; int rc; - + struct ble_att_read_req *req; /* Initialize some values in case of early error. */ - txom = NULL; - att_err = 0; - err_handle = 0; + struct os_mbuf *txom = NULL; + uint16_t err_handle = 0; + uint8_t att_err = 0; rc = ble_att_svr_pullup_req_base(rxom, sizeof(*req), &att_err); if (rc != 0) { diff --git a/nimble/host/src/ble_gatts.c b/nimble/host/src/ble_gatts.c index bf50305f4f..c45e94327a 100644 --- a/nimble/host/src/ble_gatts.c +++ b/nimble/host/src/ble_gatts.c @@ -407,21 +407,18 @@ ble_gatts_chr_val_access(uint16_t conn_handle, uint16_t attr_handle, uint8_t att_op, uint16_t offset, struct os_mbuf **om, void *arg) { - const struct ble_gatt_chr_def *chr_def; struct ble_gatt_access_ctxt gatt_ctxt; - int rc; - chr_def = arg; + const struct ble_gatt_chr_def *chr_def = arg; BLE_HS_DBG_ASSERT(chr_def != NULL && chr_def->access_cb != NULL); gatt_ctxt.op = ble_gatts_chr_op(att_op); gatt_ctxt.chr = chr_def; ble_gatts_chr_inc_val_stat(gatt_ctxt.op); - rc = ble_gatts_val_access(conn_handle, attr_handle, offset, &gatt_ctxt, om, - chr_def->access_cb, chr_def->arg); - return rc; + return ble_gatts_val_access(conn_handle, attr_handle, offset, &gatt_ctxt, om, + chr_def->access_cb, chr_def->arg); } static int diff --git a/nimble/host/src/ble_hs_hci_evt.c b/nimble/host/src/ble_hs_hci_evt.c index 48012f3b47..dfcc45f070 100644 --- a/nimble/host/src/ble_hs_hci_evt.c +++ b/nimble/host/src/ble_hs_hci_evt.c @@ -1042,7 +1042,10 @@ ble_hs_hci_evt_process(struct ble_hci_ev *ev) int ble_hs_hci_evt_acl_process(struct os_mbuf *om) { -#if NIMBLE_BLE_CONNECT +#if !NIMBLE_BLE_CONNECT + return BLE_HS_ENOTSUP; +#endif + struct hci_data_hdr hci_hdr; struct ble_hs_conn *conn; ble_l2cap_rx_fn *rx_cb; @@ -1055,8 +1058,7 @@ ble_hs_hci_evt_acl_process(struct os_mbuf *om) goto err; } -#if (BLETEST_THROUGHPUT_TEST == 0) -#if !BLE_MONITOR +#if (BLETEST_THROUGHPUT_TEST == 0) && !BLE_MONITOR BLE_HS_LOG(DEBUG, "ble_hs_hci_evt_acl_process(): conn_handle=%u pb=%x " "len=%u data=", BLE_HCI_DATA_HANDLE(hci_hdr.hdh_handle_pb_bc), @@ -1064,7 +1066,6 @@ ble_hs_hci_evt_acl_process(struct os_mbuf *om) hci_hdr.hdh_len); ble_hs_log_mbuf(om); BLE_HS_LOG(DEBUG, "\n"); -#endif #endif if (hci_hdr.hdh_len != OS_MBUF_PKTHDR(om)->omp_len) { @@ -1077,14 +1078,14 @@ ble_hs_hci_evt_acl_process(struct os_mbuf *om) ble_hs_lock(); conn = ble_hs_conn_find(conn_handle); - if (conn == NULL) { - /* Peer not connected; quietly discard packet. */ - rc = BLE_HS_ENOTCONN; - reject_cid = -1; - } else { + if (conn) { /* Forward ACL data to L2CAP. */ rc = ble_l2cap_rx(conn, &hci_hdr, om, &rx_cb, &reject_cid); om = NULL; + } else { + /* Peer not connected; quietly discard packet. */ + rc = BLE_HS_ENOTCONN; + reject_cid = -1; } ble_hs_unlock(); @@ -1113,7 +1114,4 @@ ble_hs_hci_evt_acl_process(struct os_mbuf *om) err: os_mbuf_free_chain(om); return rc; -#else - return BLE_HS_ENOTSUP; -#endif }