From 9f22db6df8671dfefe87b7b01699f22bcb1d542c Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 20 Dec 2013 09:37:00 +0200 Subject: [PATCH] emulator/bthost: Remove double lookup with bthost_find_l2cap_cb_by_psm --- emulator/bthost.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/emulator/bthost.c b/emulator/bthost.c index b324de007..8e62d26e1 100644 --- a/emulator/bthost.c +++ b/emulator/bthost.c @@ -756,6 +756,7 @@ static bool l2cap_conn_req(struct bthost *bthost, struct btconn *conn, uint8_t ident, const void *data, uint16_t len) { const struct bt_l2cap_pdu_conn_req *req = data; + struct l2cap_conn_cb_data *cb_data; struct bt_l2cap_pdu_conn_rsp rsp; uint16_t psm; @@ -767,7 +768,8 @@ static bool l2cap_conn_req(struct bthost *bthost, struct btconn *conn, memset(&rsp, 0, sizeof(rsp)); rsp.scid = req->scid; - if (bthost_find_l2cap_cb_by_psm(bthost, psm)) + cb_data = bthost_find_l2cap_cb_by_psm(bthost, psm); + if (cb_data) rsp.dcid = cpu_to_le16(conn->next_cid++); else rsp.result = cpu_to_le16(0x0002); /* PSM Not Supported */ @@ -777,7 +779,6 @@ static bool l2cap_conn_req(struct bthost *bthost, struct btconn *conn, if (!rsp.result) { struct bt_l2cap_pdu_config_req conf_req; - struct l2cap_conn_cb_data *cb_data; struct l2conn *l2conn; l2conn = bthost_add_l2cap_conn(bthost, conn, @@ -791,7 +792,6 @@ static bool l2cap_conn_req(struct bthost *bthost, struct btconn *conn, l2cap_sig_send(bthost, conn, BT_L2CAP_PDU_CONFIG_REQ, 0, &conf_req, sizeof(conf_req)); - cb_data = bthost_find_l2cap_cb_by_psm(bthost, psm); if (cb_data && l2conn->psm == cb_data->psm && cb_data->func) cb_data->func(conn->handle, l2conn->dcid, cb_data->user_data); -- 2.47.3