Bluetooth: audio: tbs_client: Remove redundant checks
The CONTAINER_OF does not return NULL, thus the `inst == NULL` checks are not needed. Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This commit is contained in:
parent
9de7cb4147
commit
1b310b26f3
1 changed files with 216 additions and 271 deletions
|
@ -614,12 +614,10 @@ static uint8_t read_bearer_provider_name_cb(struct bt_conn *conn, uint8_t err,
|
|||
const void *data, uint16_t length)
|
||||
{
|
||||
struct bt_tbs_instance *inst = CONTAINER_OF(params, struct bt_tbs_instance, read_params);
|
||||
const char *provider_name = NULL;
|
||||
|
||||
(void)memset(params, 0, sizeof(*params));
|
||||
|
||||
if (inst != NULL) {
|
||||
const char *provider_name = NULL;
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_TBS_CLIENT_GTBS) && inst->gtbs) {
|
||||
BT_DBG("GTBS");
|
||||
} else {
|
||||
|
@ -638,9 +636,7 @@ static uint8_t read_bearer_provider_name_cb(struct bt_conn *conn, uint8_t err,
|
|||
inst->busy = false;
|
||||
|
||||
if (tbs_client_cbs != NULL && tbs_client_cbs->bearer_provider_name != NULL) {
|
||||
tbs_client_cbs->bearer_provider_name(conn, err, inst->index,
|
||||
provider_name);
|
||||
}
|
||||
tbs_client_cbs->bearer_provider_name(conn, err, inst->index, provider_name);
|
||||
}
|
||||
|
||||
return BT_GATT_ITER_STOP;
|
||||
|
@ -653,12 +649,10 @@ static uint8_t read_bearer_uci_cb(struct bt_conn *conn, uint8_t err,
|
|||
const void *data, uint16_t length)
|
||||
{
|
||||
struct bt_tbs_instance *inst = CONTAINER_OF(params, struct bt_tbs_instance, read_params);
|
||||
const char *bearer_uci = NULL;
|
||||
|
||||
(void)memset(params, 0, sizeof(*params));
|
||||
|
||||
if (inst != NULL) {
|
||||
const char *bearer_uci = NULL;
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_TBS_CLIENT_GTBS) && inst->gtbs) {
|
||||
BT_DBG("GTBS");
|
||||
} else {
|
||||
|
@ -668,8 +662,7 @@ static uint8_t read_bearer_uci_cb(struct bt_conn *conn, uint8_t err,
|
|||
if (err != 0) {
|
||||
BT_DBG("err: 0x%02X", err);
|
||||
} else if (data != NULL) {
|
||||
bearer_uci = parse_string_value(data, length,
|
||||
BT_TBS_MAX_UCI_SIZE);
|
||||
bearer_uci = parse_string_value(data, length, BT_TBS_MAX_UCI_SIZE);
|
||||
BT_DBG("%s", bearer_uci);
|
||||
}
|
||||
|
||||
|
@ -678,7 +671,6 @@ static uint8_t read_bearer_uci_cb(struct bt_conn *conn, uint8_t err,
|
|||
if (tbs_client_cbs != NULL && tbs_client_cbs->bearer_uci != NULL) {
|
||||
tbs_client_cbs->bearer_uci(conn, err, inst->index, bearer_uci);
|
||||
}
|
||||
}
|
||||
|
||||
return BT_GATT_ITER_STOP;
|
||||
}
|
||||
|
@ -690,13 +682,11 @@ static uint8_t read_technology_cb(struct bt_conn *conn, uint8_t err,
|
|||
const void *data, uint16_t length)
|
||||
{
|
||||
struct bt_tbs_instance *inst = CONTAINER_OF(params, struct bt_tbs_instance, read_params);
|
||||
|
||||
(void)memset(params, 0, sizeof(*params));
|
||||
|
||||
if (inst != NULL) {
|
||||
uint8_t cb_err = err;
|
||||
uint8_t technology = 0;
|
||||
|
||||
(void)memset(params, 0, sizeof(*params));
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_TBS_CLIENT_GTBS) && inst->gtbs) {
|
||||
BT_DBG("GTBS");
|
||||
} else {
|
||||
|
@ -709,9 +699,7 @@ static uint8_t read_technology_cb(struct bt_conn *conn, uint8_t err,
|
|||
BT_HEXDUMP_DBG(data, length, "Data read");
|
||||
if (length == sizeof(technology)) {
|
||||
(void)memcpy(&technology, data, length);
|
||||
BT_DBG("%s (0x%02x)",
|
||||
bt_tbs_technology_str(technology),
|
||||
technology);
|
||||
BT_DBG("%s (0x%02x)", bt_tbs_technology_str(technology), technology);
|
||||
} else {
|
||||
BT_DBG("Invalid length");
|
||||
cb_err = BT_ATT_ERR_INVALID_ATTRIBUTE_LEN;
|
||||
|
@ -721,9 +709,7 @@ static uint8_t read_technology_cb(struct bt_conn *conn, uint8_t err,
|
|||
inst->busy = false;
|
||||
|
||||
if (tbs_client_cbs != NULL && tbs_client_cbs->technology != NULL) {
|
||||
tbs_client_cbs->technology(conn, cb_err, inst->index,
|
||||
technology);
|
||||
}
|
||||
tbs_client_cbs->technology(conn, cb_err, inst->index, technology);
|
||||
}
|
||||
|
||||
return BT_GATT_ITER_STOP;
|
||||
|
@ -736,12 +722,10 @@ static uint8_t read_uri_list_cb(struct bt_conn *conn, uint8_t err,
|
|||
const void *data, uint16_t length)
|
||||
{
|
||||
struct bt_tbs_instance *inst = CONTAINER_OF(params, struct bt_tbs_instance, read_params);
|
||||
const char *uri_scheme_list = NULL;
|
||||
|
||||
(void)memset(params, 0, sizeof(*params));
|
||||
|
||||
if (inst != NULL) {
|
||||
const char *uri_scheme_list = NULL;
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_TBS_CLIENT_GTBS) && inst->gtbs) {
|
||||
BT_DBG("GTBS");
|
||||
} else {
|
||||
|
@ -751,17 +735,14 @@ static uint8_t read_uri_list_cb(struct bt_conn *conn, uint8_t err,
|
|||
if (err != 0) {
|
||||
BT_DBG("err: 0x%02X", err);
|
||||
} else if (data != NULL) {
|
||||
uri_scheme_list = parse_string_value(data, length,
|
||||
MAX_URI_SCHEME_LIST_SIZE);
|
||||
uri_scheme_list = parse_string_value(data, length, MAX_URI_SCHEME_LIST_SIZE);
|
||||
BT_DBG("%s", uri_scheme_list);
|
||||
}
|
||||
|
||||
inst->busy = false;
|
||||
|
||||
if (tbs_client_cbs != NULL && tbs_client_cbs->uri_list != NULL) {
|
||||
tbs_client_cbs->uri_list(conn, err, inst->index,
|
||||
uri_scheme_list);
|
||||
}
|
||||
tbs_client_cbs->uri_list(conn, err, inst->index, uri_scheme_list);
|
||||
}
|
||||
|
||||
return BT_GATT_ITER_STOP;
|
||||
|
@ -774,13 +755,11 @@ static uint8_t read_signal_strength_cb(struct bt_conn *conn, uint8_t err,
|
|||
const void *data, uint16_t length)
|
||||
{
|
||||
struct bt_tbs_instance *inst = CONTAINER_OF(params, struct bt_tbs_instance, read_params);
|
||||
|
||||
(void)memset(params, 0, sizeof(*params));
|
||||
|
||||
if (inst != NULL) {
|
||||
uint8_t cb_err = err;
|
||||
uint8_t signal_strength = 0;
|
||||
|
||||
(void)memset(params, 0, sizeof(*params));
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_TBS_CLIENT_GTBS) && inst->gtbs) {
|
||||
BT_DBG("GTBS");
|
||||
} else {
|
||||
|
@ -803,9 +782,7 @@ static uint8_t read_signal_strength_cb(struct bt_conn *conn, uint8_t err,
|
|||
inst->busy = false;
|
||||
|
||||
if (tbs_client_cbs != NULL && tbs_client_cbs->signal_strength != NULL) {
|
||||
tbs_client_cbs->signal_strength(conn, cb_err, inst->index,
|
||||
signal_strength);
|
||||
}
|
||||
tbs_client_cbs->signal_strength(conn, cb_err, inst->index, signal_strength);
|
||||
}
|
||||
|
||||
return BT_GATT_ITER_STOP;
|
||||
|
@ -818,13 +795,11 @@ static uint8_t read_signal_interval_cb(struct bt_conn *conn, uint8_t err,
|
|||
const void *data, uint16_t length)
|
||||
{
|
||||
struct bt_tbs_instance *inst = CONTAINER_OF(params, struct bt_tbs_instance, read_params);
|
||||
|
||||
(void)memset(params, 0, sizeof(*params));
|
||||
|
||||
if (inst != NULL) {
|
||||
uint8_t cb_err = err;
|
||||
uint8_t signal_interval = 0;
|
||||
|
||||
(void)memset(params, 0, sizeof(*params));
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_TBS_CLIENT_GTBS) && inst->gtbs) {
|
||||
BT_DBG("GTBS");
|
||||
} else {
|
||||
|
@ -847,9 +822,7 @@ static uint8_t read_signal_interval_cb(struct bt_conn *conn, uint8_t err,
|
|||
inst->busy = false;
|
||||
|
||||
if (tbs_client_cbs && tbs_client_cbs->signal_interval) {
|
||||
tbs_client_cbs->signal_interval(conn, cb_err, inst->index,
|
||||
signal_interval);
|
||||
}
|
||||
tbs_client_cbs->signal_interval(conn, cb_err, inst->index, signal_interval);
|
||||
}
|
||||
|
||||
return BT_GATT_ITER_STOP;
|
||||
|
@ -932,13 +905,11 @@ static uint8_t read_ccid_cb(struct bt_conn *conn, uint8_t err,
|
|||
const void *data, uint16_t length)
|
||||
{
|
||||
struct bt_tbs_instance *inst = CONTAINER_OF(params, struct bt_tbs_instance, read_params);
|
||||
|
||||
(void)memset(params, 0, sizeof(*params));
|
||||
|
||||
if (inst != NULL) {
|
||||
uint8_t cb_err = err;
|
||||
uint8_t ccid = 0;
|
||||
|
||||
(void)memset(params, 0, sizeof(*params));
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_TBS_CLIENT_GTBS) && inst->gtbs) {
|
||||
BT_DBG("GTBS");
|
||||
} else {
|
||||
|
@ -963,7 +934,6 @@ static uint8_t read_ccid_cb(struct bt_conn *conn, uint8_t err,
|
|||
if (tbs_client_cbs != NULL && tbs_client_cbs->ccid != NULL) {
|
||||
tbs_client_cbs->ccid(conn, cb_err, inst->index, ccid);
|
||||
}
|
||||
}
|
||||
|
||||
return BT_GATT_ITER_STOP;
|
||||
}
|
||||
|
@ -975,13 +945,11 @@ static uint8_t read_status_flags_cb(struct bt_conn *conn, uint8_t err,
|
|||
const void *data, uint16_t length)
|
||||
{
|
||||
struct bt_tbs_instance *inst = CONTAINER_OF(params, struct bt_tbs_instance, read_params);
|
||||
|
||||
(void)memset(params, 0, sizeof(*params));
|
||||
|
||||
if (inst != NULL) {
|
||||
uint8_t cb_err = err;
|
||||
uint16_t status_flags = 0;
|
||||
|
||||
(void)memset(params, 0, sizeof(*params));
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_TBS_CLIENT_GTBS) && inst->gtbs) {
|
||||
BT_DBG("GTBS");
|
||||
} else {
|
||||
|
@ -1005,9 +973,7 @@ static uint8_t read_status_flags_cb(struct bt_conn *conn, uint8_t err,
|
|||
|
||||
if (tbs_client_cbs != NULL &&
|
||||
tbs_client_cbs->status_flags != NULL) {
|
||||
tbs_client_cbs->status_flags(conn, cb_err, inst->index,
|
||||
status_flags);
|
||||
}
|
||||
tbs_client_cbs->status_flags(conn, cb_err, inst->index, status_flags);
|
||||
}
|
||||
|
||||
return BT_GATT_ITER_STOP;
|
||||
|
@ -1020,12 +986,10 @@ static uint8_t read_call_uri_cb(struct bt_conn *conn, uint8_t err,
|
|||
const void *data, uint16_t length)
|
||||
{
|
||||
struct bt_tbs_instance *inst = CONTAINER_OF(params, struct bt_tbs_instance, read_params);
|
||||
const char *in_target_uri = NULL;
|
||||
|
||||
(void)memset(params, 0, sizeof(*params));
|
||||
|
||||
if (inst != NULL) {
|
||||
const char *in_target_uri = NULL;
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_TBS_CLIENT_GTBS) && inst->gtbs) {
|
||||
BT_DBG("GTBS");
|
||||
} else {
|
||||
|
@ -1035,18 +999,14 @@ static uint8_t read_call_uri_cb(struct bt_conn *conn, uint8_t err,
|
|||
if (err != 0) {
|
||||
BT_DBG("err: 0x%02X", err);
|
||||
} else if (data != NULL) {
|
||||
in_target_uri = parse_string_value(
|
||||
data, length,
|
||||
CONFIG_BT_TBS_MAX_URI_LENGTH);
|
||||
in_target_uri = parse_string_value(data, length, CONFIG_BT_TBS_MAX_URI_LENGTH);
|
||||
BT_DBG("%s", in_target_uri);
|
||||
}
|
||||
|
||||
inst->busy = false;
|
||||
|
||||
if (tbs_client_cbs != NULL && tbs_client_cbs->call_uri != NULL) {
|
||||
tbs_client_cbs->call_uri(conn, err, inst->index,
|
||||
in_target_uri);
|
||||
}
|
||||
tbs_client_cbs->call_uri(conn, err, inst->index, in_target_uri);
|
||||
}
|
||||
|
||||
return BT_GATT_ITER_STOP;
|
||||
|
@ -1149,13 +1109,11 @@ static uint8_t read_optional_opcodes_cb(struct bt_conn *conn, uint8_t err,
|
|||
const void *data, uint16_t length)
|
||||
{
|
||||
struct bt_tbs_instance *inst = CONTAINER_OF(params, struct bt_tbs_instance, read_params);
|
||||
|
||||
(void)memset(params, 0, sizeof(*params));
|
||||
|
||||
if (inst != NULL) {
|
||||
uint8_t cb_err = err;
|
||||
uint16_t optional_opcodes = 0;
|
||||
|
||||
(void)memset(params, 0, sizeof(*params));
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_TBS_CLIENT_GTBS) && inst->gtbs) {
|
||||
BT_DBG("GTBS");
|
||||
} else {
|
||||
|
@ -1179,10 +1137,7 @@ static uint8_t read_optional_opcodes_cb(struct bt_conn *conn, uint8_t err,
|
|||
|
||||
if (tbs_client_cbs != NULL &&
|
||||
tbs_client_cbs->optional_opcodes != NULL) {
|
||||
tbs_client_cbs->optional_opcodes(conn, cb_err,
|
||||
inst->index,
|
||||
optional_opcodes);
|
||||
}
|
||||
tbs_client_cbs->optional_opcodes(conn, cb_err, inst->index, optional_opcodes);
|
||||
}
|
||||
|
||||
return BT_GATT_ITER_STOP;
|
||||
|
@ -1195,12 +1150,10 @@ static uint8_t read_remote_uri_cb(struct bt_conn *conn, uint8_t err,
|
|||
const void *data, uint16_t length)
|
||||
{
|
||||
struct bt_tbs_instance *inst = CONTAINER_OF(params, struct bt_tbs_instance, read_params);
|
||||
const char *remote_uri = NULL;
|
||||
|
||||
(void)memset(params, 0, sizeof(*params));
|
||||
|
||||
if (inst != NULL) {
|
||||
const char *remote_uri = NULL;
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_TBS_CLIENT_GTBS) && inst->gtbs) {
|
||||
BT_DBG("GTBS");
|
||||
} else {
|
||||
|
@ -1210,8 +1163,7 @@ static uint8_t read_remote_uri_cb(struct bt_conn *conn, uint8_t err,
|
|||
if (err != 0) {
|
||||
BT_DBG("err: 0x%02X", err);
|
||||
} else if (data != NULL) {
|
||||
remote_uri = parse_string_value(data, length,
|
||||
CONFIG_BT_TBS_MAX_URI_LENGTH);
|
||||
remote_uri = parse_string_value(data, length, CONFIG_BT_TBS_MAX_URI_LENGTH);
|
||||
BT_DBG("%s", remote_uri);
|
||||
}
|
||||
|
||||
|
@ -1219,9 +1171,7 @@ static uint8_t read_remote_uri_cb(struct bt_conn *conn, uint8_t err,
|
|||
|
||||
if (tbs_client_cbs != NULL &&
|
||||
tbs_client_cbs->remote_uri != NULL) {
|
||||
tbs_client_cbs->remote_uri(conn, err, inst->index,
|
||||
remote_uri);
|
||||
}
|
||||
tbs_client_cbs->remote_uri(conn, err, inst->index, remote_uri);
|
||||
}
|
||||
|
||||
return BT_GATT_ITER_STOP;
|
||||
|
@ -1234,12 +1184,10 @@ static uint8_t read_friendly_name_cb(struct bt_conn *conn, uint8_t err,
|
|||
const void *data, uint16_t length)
|
||||
{
|
||||
struct bt_tbs_instance *inst = CONTAINER_OF(params, struct bt_tbs_instance, read_params);
|
||||
const char *friendly_name = NULL;
|
||||
|
||||
(void)memset(params, 0, sizeof(*params));
|
||||
|
||||
if (inst != NULL) {
|
||||
const char *friendly_name = NULL;
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_TBS_CLIENT_GTBS) && inst->gtbs) {
|
||||
BT_DBG("GTBS");
|
||||
} else {
|
||||
|
@ -1249,17 +1197,14 @@ static uint8_t read_friendly_name_cb(struct bt_conn *conn, uint8_t err,
|
|||
if (err != 0) {
|
||||
BT_DBG("err: 0x%02X", err);
|
||||
} else if (data != NULL) {
|
||||
friendly_name = parse_string_value(data, length,
|
||||
CONFIG_BT_TBS_MAX_URI_LENGTH);
|
||||
friendly_name = parse_string_value(data, length, CONFIG_BT_TBS_MAX_URI_LENGTH);
|
||||
BT_DBG("%s", friendly_name);
|
||||
}
|
||||
inst->busy = false;
|
||||
|
||||
if (tbs_client_cbs != NULL &&
|
||||
tbs_client_cbs->friendly_name != NULL) {
|
||||
tbs_client_cbs->friendly_name(conn, err, inst->index,
|
||||
friendly_name);
|
||||
}
|
||||
tbs_client_cbs->friendly_name(conn, err, inst->index, friendly_name);
|
||||
}
|
||||
|
||||
return BT_GATT_ITER_STOP;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue