Bluetooth: Audio: Fix CSIP compliance check with returns after else
The compliance check did not like the otherwise valid way of returning from read_set_sirk. The code has been slightly refactored to avoid the check failing in CI. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
parent
292db21a18
commit
43e0a63996
1 changed files with 14 additions and 8 deletions
|
@ -237,6 +237,7 @@ static ssize_t read_set_sirk(struct bt_conn *conn,
|
||||||
struct bt_csip_set_member_svc_inst *svc_inst = BT_AUDIO_CHRC_USER_DATA(attr);
|
struct bt_csip_set_member_svc_inst *svc_inst = BT_AUDIO_CHRC_USER_DATA(attr);
|
||||||
|
|
||||||
if (svc_inst->cb != NULL && svc_inst->cb->sirk_read_req != NULL) {
|
if (svc_inst->cb != NULL && svc_inst->cb->sirk_read_req != NULL) {
|
||||||
|
ssize_t gatt_err = BT_GATT_ERR(BT_ATT_ERR_SUCCESS);
|
||||||
uint8_t cb_rsp;
|
uint8_t cb_rsp;
|
||||||
|
|
||||||
/* Ask higher layer for what SIRK to return, if any */
|
/* Ask higher layer for what SIRK to return, if any */
|
||||||
|
@ -253,19 +254,24 @@ static ssize_t read_set_sirk(struct bt_conn *conn,
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
BT_ERR("Could not encrypt SIRK: %d",
|
BT_ERR("Could not encrypt SIRK: %d",
|
||||||
err);
|
err);
|
||||||
return BT_GATT_ERR(BT_ATT_ERR_UNLIKELY);
|
gatt_err = BT_GATT_ERR(BT_ATT_ERR_UNLIKELY);
|
||||||
|
} else {
|
||||||
|
sirk = &enc_sirk;
|
||||||
|
LOG_HEXDUMP_DBG(enc_sirk.value,
|
||||||
|
sizeof(enc_sirk.value),
|
||||||
|
"Encrypted Set SIRK");
|
||||||
}
|
}
|
||||||
|
|
||||||
sirk = &enc_sirk;
|
|
||||||
LOG_HEXDUMP_DBG(enc_sirk.value, sizeof(enc_sirk.value),
|
|
||||||
"Encrypted Set SIRK");
|
|
||||||
} else if (cb_rsp == BT_CSIP_READ_SIRK_REQ_RSP_REJECT) {
|
} else if (cb_rsp == BT_CSIP_READ_SIRK_REQ_RSP_REJECT) {
|
||||||
return BT_GATT_ERR(BT_ATT_ERR_AUTHORIZATION);
|
gatt_err = BT_GATT_ERR(BT_ATT_ERR_AUTHORIZATION);
|
||||||
} else if (cb_rsp == BT_CSIP_READ_SIRK_REQ_RSP_OOB_ONLY) {
|
} else if (cb_rsp == BT_CSIP_READ_SIRK_REQ_RSP_OOB_ONLY) {
|
||||||
return BT_GATT_ERR(BT_CSIP_ERROR_SIRK_OOB_ONLY);
|
gatt_err = BT_GATT_ERR(BT_CSIP_ERROR_SIRK_OOB_ONLY);
|
||||||
} else {
|
} else {
|
||||||
BT_ERR("Invalid callback response: %u", cb_rsp);
|
BT_ERR("Invalid callback response: %u", cb_rsp);
|
||||||
return BT_GATT_ERR(BT_ATT_ERR_UNLIKELY);
|
gatt_err = BT_GATT_ERR(BT_ATT_ERR_UNLIKELY);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gatt_err != BT_GATT_ERR(BT_ATT_ERR_SUCCESS)) {
|
||||||
|
return gatt_err;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sirk = &svc_inst->set_sirk;
|
sirk = &svc_inst->set_sirk;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue