nimble/ll: Improve indentation
Remove unnecessary nested if-s.
@@ -3452,12 +3452,19 @@ ble_ll_conn_rx_data_pdu(struct os_mbuf *rxpdu, struct ble_mbuf_hdr *hdr)
uint16_t acl_hdr;
struct ble_ll_conn_sm *connsm;
- if (BLE_MBUF_HDR_CRC_OK(hdr)) {
+ if (!BLE_MBUF_HDR_CRC_OK(hdr)) {
+ goto conn_rx_data_pdu_end;
+ }
+
/* XXX: there is a chance that the connection was thrown away and
re-used before processing packets here. Fix this. */
/* We better have a connection state machine */
connsm = ble_ll_conn_find_active_conn(hdr->rxinfo.handle);
- if (connsm) {
+ if (!connsm) {
+ STATS_INC(ble_ll_conn_stats, no_conn_sm);
+ goto conn_rx_data_pdu_end;
+ }
+
/* Check state machine */
ble_ll_conn_chk_csm_flags(connsm);
@@ -3471,8 +3478,7 @@ ble_ll_conn_rx_data_pdu(struct os_mbuf *rxpdu, struct ble_mbuf_hdr *hdr)
* Check that the LLID and payload length are reasonable.
* Empty payload is only allowed for LLID == 01b.
* */
- if ((llid == 0) ||
- ((acl_len == 0) && (llid != BLE_LL_LLID_DATA_FRAG))) {
+ if ((llid == 0) || ((acl_len == 0) && (llid != BLE_LL_LLID_DATA_FRAG))) {
STATS_INC(ble_ll_conn_stats, rx_bad_llid);
goto conn_rx_data_pdu_end;
}
@@ -3520,7 +3526,11 @@ ble_ll_conn_rx_data_pdu(struct os_mbuf *rxpdu, struct ble_mbuf_hdr *hdr)
* as the last received sequence number
*/
rxd_sn = hdr_byte & BLE_LL_DATA_HDR_SN_MASK;
- if (rxd_sn != connsm->last_rxd_sn) {
+ if (rxd_sn == connsm->last_rxd_sn) {
+ STATS_INC(ble_ll_conn_stats, data_pdu_rx_dup);
+ goto conn_rx_data_pdu_end;
+ }
+
/* Update last rxd sn */
connsm->last_rxd_sn = rxd_sn;
@@ -3565,13 +3575,6 @@ ble_ll_conn_rx_data_pdu(struct os_mbuf *rxpdu, struct ble_mbuf_hdr *hdr)
/* NOTE: we dont free the mbuf since we handed it off! */
return;
- } else {
- STATS_INC(ble_ll_conn_stats, data_pdu_rx_dup);
- }
- } else {
- STATS_INC(ble_ll_conn_stats, no_conn_sm);
- }
- }
/* Free buffer */
conn_rx_data_pdu_end:
