Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5038ccf2 authored by Chris Manton's avatar Chris Manton
Browse files

stack::sdp: Declare and assign tCONN_CB together

Bug: 352106391
Test: m .
Flag: EXEMPT, Mechanical refactor
Change-Id: I39b01a83d5b76f2ee5fc8d0edf9302c58591b214
parent 76c0f5ec
Loading
Loading
Loading
Loading
+3 −12
Original line number Diff line number Diff line
@@ -136,11 +136,8 @@ bool SDP_CancelServiceSearch(const tSDP_DISCOVERY_DB* p_db) {
 ******************************************************************************/
bool SDP_ServiceSearchRequest(const RawAddress& bd_addr, tSDP_DISCOVERY_DB* p_db,
                              tSDP_DISC_CMPL_CB* p_cb) {
  tCONN_CB* p_ccb;

  /* Specific BD address */
  p_ccb = sdp_conn_originate(bd_addr);

  tCONN_CB* p_ccb = sdp_conn_originate(bd_addr);
  if (!p_ccb) {
    return false;
  }
@@ -168,11 +165,8 @@ bool SDP_ServiceSearchRequest(const RawAddress& bd_addr, tSDP_DISCOVERY_DB* p_db
 ******************************************************************************/
bool SDP_ServiceSearchAttributeRequest(const RawAddress& bd_addr, tSDP_DISCOVERY_DB* p_db,
                                       tSDP_DISC_CMPL_CB* p_cb) {
  tCONN_CB* p_ccb;

  /* Specific BD address */
  p_ccb = sdp_conn_originate(bd_addr);

  tCONN_CB* p_ccb = sdp_conn_originate(bd_addr);
  if (!p_ccb) {
    return false;
  }
@@ -202,11 +196,8 @@ bool SDP_ServiceSearchAttributeRequest(const RawAddress& bd_addr, tSDP_DISCOVERY
bool SDP_ServiceSearchAttributeRequest2(
        const RawAddress& bd_addr, tSDP_DISCOVERY_DB* p_db,
        base::RepeatingCallback<tSDP_DISC_CMPL_CB> complete_callback) {
  tCONN_CB* p_ccb;

  /* Specific BD address */
  p_ccb = sdp_conn_originate(bd_addr);

  tCONN_CB* p_ccb = sdp_conn_originate(bd_addr);
  if (!p_ccb) {
    return false;
  }
+7 −20
Original line number Diff line number Diff line
@@ -95,10 +95,8 @@ static void sdp_on_l2cap_error(uint16_t l2cap_cid, uint16_t /* result */) {
 *
 ******************************************************************************/
static void sdp_connect_cfm(uint16_t l2cap_cid, uint16_t result) {
  tCONN_CB* p_ccb;

  /* Find CCB based on CID */
  p_ccb = sdpu_find_ccb_by_cid(l2cap_cid);
  tCONN_CB* p_ccb = sdpu_find_ccb_by_cid(l2cap_cid);
  if (p_ccb == NULL) {
    log::warn("SDP - Rcvd conn cnf for unknown CID 0x{:x}", l2cap_cid);
    sdpu_dump_all_ccb();
@@ -125,10 +123,8 @@ static void sdp_connect_cfm(uint16_t l2cap_cid, uint16_t result) {
 *
 ******************************************************************************/
static void sdp_config_ind(uint16_t l2cap_cid, tL2CAP_CFG_INFO* p_cfg) {
  tCONN_CB* p_ccb;

  /* Find CCB based on CID */
  p_ccb = sdpu_find_ccb_by_cid(l2cap_cid);
  tCONN_CB* p_ccb = sdpu_find_ccb_by_cid(l2cap_cid);
  if (p_ccb == NULL) {
    log::warn("SDP - Rcvd L2CAP cfg ind, unknown CID: 0x{:x}", l2cap_cid);
    sdpu_dump_all_ccb();
@@ -163,12 +159,10 @@ static void sdp_config_ind(uint16_t l2cap_cid, tL2CAP_CFG_INFO* p_cfg) {
static void sdp_config_cfm(uint16_t l2cap_cid, uint16_t /* initiator */, tL2CAP_CFG_INFO* p_cfg) {
  sdp_config_ind(l2cap_cid, p_cfg);

  tCONN_CB* p_ccb;

  log::verbose("SDP - Rcvd cfg cfm, CID: 0x{:x}", l2cap_cid);

  /* Find CCB based on CID */
  p_ccb = sdpu_find_ccb_by_cid(l2cap_cid);
  tCONN_CB* p_ccb = sdpu_find_ccb_by_cid(l2cap_cid);
  if (p_ccb == NULL) {
    log::warn("SDP - Rcvd L2CAP cfg ind, unknown CID: 0x{:x}", l2cap_cid);
    sdpu_dump_all_ccb();
@@ -197,10 +191,8 @@ static void sdp_config_cfm(uint16_t l2cap_cid, uint16_t /* initiator */, tL2CAP_
 *
 ******************************************************************************/
static void sdp_disconnect_ind(uint16_t l2cap_cid, bool ack_needed) {
  tCONN_CB* p_ccb;

  /* Find CCB based on CID */
  p_ccb = sdpu_find_ccb_by_cid(l2cap_cid);
  tCONN_CB* p_ccb = sdpu_find_ccb_by_cid(l2cap_cid);
  if (p_ccb == NULL) {
    log::warn("SDP - Rcvd L2CAP disc, unknown CID: 0x{:x}", l2cap_cid);
    sdpu_dump_all_ccb();
@@ -239,10 +231,8 @@ static void sdp_disconnect_ind(uint16_t l2cap_cid, bool ack_needed) {
 *
 ******************************************************************************/
static void sdp_data_ind(uint16_t l2cap_cid, BT_HDR* p_msg) {
  tCONN_CB* p_ccb;

  /* Find CCB based on CID */
  p_ccb = sdpu_find_ccb_by_cid(l2cap_cid);
  tCONN_CB* p_ccb = sdpu_find_ccb_by_cid(l2cap_cid);
  if (p_ccb != NULL) {
    if (p_ccb->con_state == tSDP_STATE::CONNECTED) {
      if (p_ccb->con_flags & SDP_FLAGS_IS_ORIG) {
@@ -273,11 +263,10 @@ static void sdp_data_ind(uint16_t l2cap_cid, BT_HDR* p_msg) {
 *
 ******************************************************************************/
tCONN_CB* sdp_conn_originate(const RawAddress& bd_addr) {
  tCONN_CB* p_ccb;
  uint16_t cid;

  /* Allocate a new CCB. Return if none available. */
  p_ccb = sdpu_allocate_ccb();
  tCONN_CB* p_ccb = sdpu_allocate_ccb();
  if (p_ccb == NULL) {
    log::warn("no spare CCB for peer {}", bd_addr);
    return NULL;
@@ -360,10 +349,8 @@ void sdp_disconnect(tCONN_CB* p_ccb, tSDP_REASON reason) {
 *
 ******************************************************************************/
static void sdp_disconnect_cfm(uint16_t l2cap_cid, uint16_t /* result */) {
  tCONN_CB* p_ccb;

  /* Find CCB based on CID */
  p_ccb = sdpu_find_ccb_by_cid(l2cap_cid);
  tCONN_CB* p_ccb = sdpu_find_ccb_by_cid(l2cap_cid);
  if (p_ccb == NULL) {
    log::warn("SDP - Rcvd L2CAP disc cfm, unknown CID: 0x{:x}", l2cap_cid);
    sdpu_dump_all_ccb();
+7 −7
Original line number Diff line number Diff line
@@ -311,7 +311,7 @@ void sdpu_log_attribute_metrics(const RawAddress& bda, tSDP_DISCOVERY_DB* p_db)
 ******************************************************************************/
tCONN_CB* sdpu_find_ccb_by_cid(uint16_t cid) {
  uint16_t xx;
  tCONN_CB* p_ccb;
  tCONN_CB* p_ccb{};

  /* Look through each connection control block */
  for (xx = 0, p_ccb = sdp_cb.ccb; xx < SDP_MAX_CONNECTIONS; xx++, p_ccb++) {
@@ -337,7 +337,7 @@ tCONN_CB* sdpu_find_ccb_by_cid(uint16_t cid) {
 ******************************************************************************/
tCONN_CB* sdpu_find_ccb_by_db(const tSDP_DISCOVERY_DB* p_db) {
  uint16_t xx;
  tCONN_CB* p_ccb;
  tCONN_CB* p_ccb{};

  if (p_db) {
    /* Look through each connection control block */
@@ -362,7 +362,7 @@ tCONN_CB* sdpu_find_ccb_by_db(const tSDP_DISCOVERY_DB* p_db) {
 ******************************************************************************/
tCONN_CB* sdpu_allocate_ccb(void) {
  uint16_t xx;
  tCONN_CB* p_ccb;
  tCONN_CB* p_ccb{};

  /* Look through each connection control block for a free one */
  for (xx = 0, p_ccb = sdp_cb.ccb; xx < SDP_MAX_CONNECTIONS; xx++, p_ccb++) {
@@ -452,7 +452,7 @@ void sdpu_dump_all_ccb() {
 ******************************************************************************/
uint16_t sdpu_get_active_ccb_cid(const RawAddress& bd_addr) {
  uint16_t xx;
  tCONN_CB* p_ccb;
  tCONN_CB* p_ccb{};

  // Look through each connection control block for active sdp on given remote
  for (xx = 0, p_ccb = sdp_cb.ccb; xx < SDP_MAX_CONNECTIONS; xx++, p_ccb++) {
@@ -483,7 +483,7 @@ uint16_t sdpu_get_active_ccb_cid(const RawAddress& bd_addr) {
 ******************************************************************************/
bool sdpu_process_pend_ccb_same_cid(tCONN_CB& ccb) {
  uint16_t xx;
  tCONN_CB* p_ccb;
  tCONN_CB* p_ccb{};

  // Look through each connection control block for active sdp on given remote
  for (xx = 0, p_ccb = sdp_cb.ccb; xx < SDP_MAX_CONNECTIONS; xx++, p_ccb++) {
@@ -512,7 +512,7 @@ bool sdpu_process_pend_ccb_same_cid(tCONN_CB& ccb) {
 ******************************************************************************/
bool sdpu_process_pend_ccb_new_cid(tCONN_CB& ccb) {
  uint16_t xx;
  tCONN_CB* p_ccb;
  tCONN_CB* p_ccb{};
  uint16_t new_cid = 0;
  bool new_conn = false;

@@ -552,7 +552,7 @@ bool sdpu_process_pend_ccb_new_cid(tCONN_CB& ccb) {
 ******************************************************************************/
void sdpu_clear_pend_ccb(tCONN_CB& ccb) {
  uint16_t xx;
  tCONN_CB* p_ccb;
  tCONN_CB* p_ccb{};

  // Look through each connection control block for active sdp on given remote
  for (xx = 0, p_ccb = sdp_cb.ccb; xx < SDP_MAX_CONNECTIONS; xx++, p_ccb++) {