Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

L2CAP functions simplification [WIP] #1849

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions nimble/host/src/ble_hs_hci_evt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,7 @@ ble_hs_hci_evt_acl_process(struct os_mbuf *om)
/* Final fragment received. */
BLE_HS_DBG_ASSERT(rx_cb != NULL);
rc = rx_cb(conn->bhc_rx_chan);
// REVIEW: Seems like the function ble_l2cap_remove_rx could use only one argument conn, it could take chan from the conn. ble_l2cap_rx uses it. It's called if channel for recieved packet has rx_buf. Will conn->bhc_rx_chan be equal to chan->rx_buf in this case?
ble_l2cap_remove_rx(conn, conn->bhc_rx_chan);
break;

Expand Down
5 changes: 5 additions & 0 deletions nimble/host/src/ble_l2cap.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,12 @@

*out_reject_cid = -1;

// REVIEW: The function is dependent only on PB, this could be passed instead of the whole struct. Could we change this?
pb = BLE_HCI_DATA_PB(hci_hdr->hdh_handle_pb_bc);
switch (pb) {
case BLE_HCI_PB_FIRST_FLUSH:
/* First fragment. */
// REVIEW: Could change this to ble_l2cap_strip_hdr (parse + strip) in analogy to ble_hs_hci_util_data_hdr_strip.
rc = ble_l2cap_parse_hdr(om, 0, &l2cap_hdr);
if (rc != 0) {
goto err;
Expand Down Expand Up @@ -427,7 +429,10 @@
goto err;
}

// REVIEW: It would be nice not to pass conn to decrease number of arguments, timer reschedule could be processed here. Actually it could be hoisted to the caller as it already processes the return value and knows about l2cap fragments existence. So just return ble_l2cap_rx_payload(chan, om, out_rx_cb);

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
rc = ble_l2cap_rx_payload(conn, chan, om, out_rx_cb);
// REVIEW: There is no need to nullify the pointer, it's nullified in the caller.
// Also I believe this function shouldn't own the buffer and try to free it, it's the caller duty, just return the error from this function, and caller decides what to do. It'll simplify the code in this function a bit.
om = NULL;
if (rc != 0) {
goto err;
Expand Down
Loading