diff --git a/health/hdp_util.c b/health/hdp_util.c
index e62ed46..7a234c1 100644
--- a/health/hdp_util.c
+++ b/health/hdp_util.c
/* set l2cap information */
sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
l2cap_list = sdp_list_append(NULL, &l2cap_uuid);
- if (!l2cap_list) {
+ if (l2cap_list == NULL) {
ret = FALSE;
goto end;
}
psm = sdp_data_alloc(SDP_UINT16, &adapter->ccpsm);
- if (!psm) {
+ if (psm == NULL) {
ret = FALSE;
goto end;
}
- if (!sdp_list_append(l2cap_list, psm)) {
+ if (sdp_list_append(l2cap_list, psm) == NULL) {
ret = FALSE;
goto end;
}
proto_list = sdp_list_append(NULL, l2cap_list);
- if (!proto_list) {
+ if (proto_list == NULL) {
ret = FALSE;
goto end;
}
/* set mcap information */
sdp_uuid16_create(&mcap_c_uuid, MCAP_CTRL_UUID);
mcap_list = sdp_list_append(NULL, &mcap_c_uuid);
- if (!mcap_list) {
+ if (mcap_list == NULL) {
ret = FALSE;
goto end;
}
mcap_ver = sdp_data_alloc(SDP_UINT16, &version);
- if (!mcap_ver) {
+ if (mcap_ver == NULL) {
ret = FALSE;
goto end;
}
- if (!sdp_list_append(mcap_list, mcap_ver)) {
+ if (sdp_list_append(mcap_list, mcap_ver) == NULL) {
ret = FALSE;
goto end;
}
- if (!sdp_list_append(proto_list, mcap_list)) {
+ if (sdp_list_append(proto_list, mcap_list) == NULL) {
ret = FALSE;
goto end;
}
/* attach protocol information to service record */
access_proto_list = sdp_list_append(NULL, proto_list);
- if (!access_proto_list) {
+ if (access_proto_list == NULL) {
ret = FALSE;
goto end;
}
ret = TRUE;
end:
- if (l2cap_list)
+ if (l2cap_list != NULL)
sdp_list_free(l2cap_list, NULL);
- if (mcap_list)
+ if (mcap_list != NULL)
sdp_list_free(mcap_list, NULL);
- if (proto_list)
+ if (proto_list != NULL)
sdp_list_free(proto_list, NULL);
- if (access_proto_list)
+ if (access_proto_list != NULL)
sdp_list_free(access_proto_list, NULL);
- if (psm)
+ if (psm != NULL)
sdp_data_free(psm);
- if (mcap_ver)
+ if (mcap_ver != NULL)
sdp_data_free(mcap_ver);
return ret;
sdp_uuid16_create(&hdp_profile.uuid, HDP_SVCLASS_ID);
hdp_profile.version = HDP_VERSION;
profile_list = sdp_list_append(NULL, &hdp_profile);
- if (!profile_list)
+ if (profile_list == NULL)
return FALSE;
/* set profile descriptor list */
/* set l2cap information */
sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
l2cap_list = sdp_list_append(NULL, &l2cap_uuid);
- if (!l2cap_list) {
+ if (l2cap_list == NULL) {
ret = FALSE;
goto end;
}
psm = sdp_data_alloc(SDP_UINT16, &adapter->dcpsm);
- if (!psm) {
+ if (psm == NULL) {
ret = FALSE;
goto end;
}
- if (!sdp_list_append(l2cap_list, psm)) {
+ if (sdp_list_append(l2cap_list, psm) == NULL) {
ret = FALSE;
goto end;
}
proto_list = sdp_list_append(NULL, l2cap_list);
- if (!proto_list) {
+ if (proto_list == NULL) {
ret = FALSE;
goto end;
}
/* set mcap information */
sdp_uuid16_create(&mcap_d_uuid, MCAP_DATA_UUID);
mcap_list = sdp_list_append(NULL, &mcap_d_uuid);
- if (!mcap_list) {
+ if (mcap_list == NULL) {
ret = FALSE;
goto end;
}
- if (!sdp_list_append(proto_list, mcap_list)) {
+ if (sdp_list_append(proto_list, mcap_list) == NULL) {
ret = FALSE;
goto end;
}
/* attach protocol information to service record */
access_proto_list = sdp_list_append(NULL, proto_list);
- if (!access_proto_list) {
+ if (access_proto_list == NULL) {
ret = FALSE;
goto end;
}
ret = TRUE;
end:
- if (l2cap_list)
+ if (l2cap_list != NULL)
sdp_list_free(l2cap_list, NULL);
- if (mcap_list)
+ if (mcap_list != NULL)
sdp_list_free(mcap_list, NULL);
- if (proto_list)
+ if (proto_list != NULL)
sdp_list_free(proto_list, NULL);
- if (access_proto_list)
+ if (access_proto_list != NULL)
sdp_list_free(access_proto_list, NULL);
- if (psm)
+ if (psm != NULL)
sdp_data_free(psm);
return ret;
sdp_list_t *f_list = NULL;
mdepid = sdp_data_alloc(SDP_UINT8, &app->id);
- if (!mdepid)
+ if (mdepid == NULL)
return NULL;
dtype = sdp_data_alloc(SDP_UINT16, &app->data_type);
- if (!dtype)
+ if (dtype == NULL)
goto fail;
role = sdp_data_alloc(SDP_UINT8, &app->role);
- if (!role)
+ if (role == NULL)
goto fail;
- if (app->description) {
+ if (app->description != NULL) {
desc = sdp_data_alloc(SDP_TEXT_STR8, app->description);
- if (!desc)
+ if (desc == NULL)
goto fail;
}
f_list = sdp_list_append(NULL, mdepid);
- if (!f_list)
+ if (f_list == NULL)
goto fail;
- if (!sdp_list_append(f_list, dtype))
+ if (sdp_list_append(f_list, dtype) == NULL)
goto fail;
- if (!sdp_list_append(f_list, role))
+ if (sdp_list_append(f_list, role) == NULL)
goto fail;
- if (desc)
- if (!sdp_list_append(f_list, desc))
+ if (desc != NULL)
+ if (sdp_list_append(f_list, desc) == NULL)
goto fail;
return f_list;
fail:
- if (f_list)
+ if (f_list != NULL)
sdp_list_free(f_list, NULL);
- if (mdepid)
+ if (mdepid != NULL)
sdp_data_free(mdepid);
- if (dtype)
+ if (dtype != NULL)
sdp_data_free(dtype);
- if (role)
+ if (role != NULL)
sdp_data_free(role);
- if (desc)
+ if (desc != NULL)
sdp_data_free(desc);
return NULL;
sdp_list_t *hdp_feature;
hdp_feature = app_to_sdplist(app);
- if (!hdp_feature)
+ if (hdp_feature == NULL)
goto fail;
- if (!*sup_features) {
+ if (*sup_features == NULL) {
*sup_features = sdp_list_append(NULL, hdp_feature);
- if (!*sup_features)
+ if (*sup_features == NULL)
goto fail;
- } else if (!sdp_list_append(*sup_features, hdp_feature)) {
+ } else if (sdp_list_append(*sup_features, hdp_feature) == NULL) {
goto fail;
}
return TRUE;
fail:
- if (hdp_feature)
+ if (hdp_feature != NULL)
sdp_list_free(hdp_feature, (sdp_free_func_t)sdp_data_free);
return FALSE;
}
/* As by now 11073 is the only supported we set it by default */
spec = sdp_data_alloc(SDP_UINT8, &data_spec);
- if (!spec)
+ if (spec == NULL)
return FALSE;
if (sdp_attr_add(record, SDP_ATTR_DATA_EXCHANGE_SPEC, spec) < 0) {
uint8_t mcap_sup_proc = MCAP_SUP_PROC;
mcap_proc = sdp_data_alloc(SDP_UINT8, &mcap_sup_proc);
- if (!mcap_proc)
+ if (mcap_proc == NULL)
return FALSE;
if (sdp_attr_add(sdp_record, SDP_ATTR_MCAP_SUPPORTED_PROCEDURES,
sdp_record_t *sdp_record;
bdaddr_t addr;
- if (adapter->sdp_handler)
+ if (adapter->sdp_handler > 0)
remove_record_from_server(adapter->sdp_handler);
- if (!app_list) {
+ if (app_list == NULL) {
adapter->sdp_handler = 0;
return TRUE;
}
sdp_record = sdp_record_alloc();
- if (!sdp_record)
+ if (sdp_record == NULL)
return FALSE;
- if (adapter->sdp_handler)
+ if (adapter->sdp_handler > 0)
sdp_record->handle = adapter->sdp_handler;
else
sdp_record->handle = 0xffffffff; /* Set automatically */
register_mcap_features(sdp_record);
- if (sdp_set_record_state(sdp_record, adapter->record_state++))
+ if (sdp_set_record_state(sdp_record, adapter->record_state++) < 0)
goto fail;
adapter_get_address(adapter->btd_adapter, &addr);
return TRUE;
fail:
- if (sdp_record)
+ if (sdp_record != NULL)
sdp_record_free(sdp_record);
return FALSE;
}
{
sdp_data_t *list, *feat;
- if (!desc && !mdep)
+ if (desc == NULL && mdep == NULL)
return TRUE;
list = sdp_data_get(rec, SDP_ATTR_SUPPORTED_FEATURES_LIST);
continue;
mdepid = feat->val.dataseq;
- if (!mdepid)
+ if (mdepid == NULL)
continue;
data_type = mdepid->next;
- if (!data_type)
+ if (data_type == NULL)
continue;
role_t = data_type->next;
- if (!role_t)
+ if (role_t == NULL)
continue;
desc_t = role_t->next;
!check_role(role_t->val.uint8, role))
continue;
- if (mdep)
+ if (mdep != NULL)
*mdep = mdepid->val.uint8;
- if (desc && desc_t && (desc_t->dtd == SDP_TEXT_STR8 ||
+ if (desc != NULL && desc_t != NULL &&
+ (desc_t->dtd == SDP_TEXT_STR8 ||
desc_t->dtd == SDP_TEXT_STR16 ||
desc_t->dtd == SDP_TEXT_STR32))
*desc = g_strdup(desc_t->val.str);
GError *gerr = NULL;
uint8_t mdep;
- if (err || !recs) {
+ if (err < 0 || recs == NULL) {
g_set_error(&gerr, HDP_ERROR, HDP_CONNECTION_ERROR,
"Error getting remote SDP records");
mdep_data->func(0, mdep_data->data, gerr);
bt_string2uuid(&uuid, HDP_UUID);
if (bt_search_service(&src, &dst, &uuid, get_mdep_cb, mdep_data,
- free_mdep_data)) {
+ free_mdep_data) < 0) {
g_set_error(err, HDP_ERROR, HDP_CONNECTION_ERROR,
"Can't get remote SDP record");
g_free(mdep_data);
sdp_data_t *iter;
int proto;
- if (!entry || (entry->dtd != SDP_SEQ8 && entry->dtd != SDP_SEQ16 &&
- entry->dtd != SDP_SEQ32))
+ if (entry == NULL || (entry->dtd != SDP_SEQ8 &&
+ entry->dtd != SDP_SEQ16 && entry->dtd != SDP_SEQ32))
return FALSE;
iter = entry->val.dataseq;
if (proto != type)
return FALSE;
- if (!val)
+ if (val == NULL)
return TRUE;
iter = iter->next;
{
sdp_data_t *pdl, *p0, *p1;
- if (!psm && !version)
+ if (psm == NULL && version == NULL)
return TRUE;
pdl = sdp_data_get(rec, SDP_ATTR_PROTO_DESC_LIST);
{
sdp_data_t *pdl, *p0, *p1;
- if (!psm)
+ if (psm == NULL)
return TRUE;
pdl = sdp_data_get(rec, SDP_ATTR_ADD_PROTO_DESC_LIST);
static void con_mcl_data_unref(struct conn_mcl_data *conn_data)
{
- if (!conn_data)
+ if (conn_data == NULL)
return;
if (--conn_data->refs > 0)
static struct conn_mcl_data *con_mcl_data_ref(struct conn_mcl_data *conn_data)
{
- if (!conn_data)
+ if (conn_data == NULL)
return NULL;
conn_data->refs++;
struct hdp_device *device = conn_data->dev;
GError *gerr = NULL;
- if (err) {
+ if (err != NULL) {
conn_data->func(conn_data->data, err);
return;
}
- if (!device->mcl)
+ if (device->mcl == NULL)
device->mcl = mcap_mcl_ref(mcl);
device->mcl_conn = TRUE;
hdp_set_mcl_cb(device, &gerr);
conn_data->func(conn_data->data, gerr);
- if (gerr)
+ if (gerr != NULL)
g_error_free(gerr);
}
bdaddr_t dst;
uint16_t ccpsm;
- if (!conn_data->dev->hdp_adapter->mi) {
+ if (conn_data->dev->hdp_adapter->mi == NULL) {
g_set_error(&gerr, HDP_ERROR, HDP_CONNECTION_ERROR,
"Mcap instance released");
goto fail;
}
- if (err || !recs) {
+ if (err < 0 || recs == NULL) {
g_set_error(&gerr, HDP_ERROR, HDP_CONNECTION_ERROR,
"Error getting remote SDP records");
goto fail;
bt_string2uuid(&uuid, HDP_UUID);
if (bt_search_service(&src, &dst, &uuid, search_cb, conn_data,
- destroy_con_mcl_data)) {
+ destroy_con_mcl_data) < 0) {
g_set_error(err, HDP_ERROR, HDP_CONNECTION_ERROR,
"Can't get remote SDP record");
g_free(conn_data);
GError *gerr = NULL;
uint16_t dcpsm;
- if (err || !recs) {
+ if (err < 0 || recs == NULL) {
g_set_error(&gerr, HDP_ERROR, HDP_CONNECTION_ERROR,
"Error getting remote SDP records");
goto fail;
{
struct get_dcpsm_data *dcpsm_data = data;
- if (!dcpsm_data)
+ if (dcpsm_data == NULL)
return;
if (dcpsm_data->destroy)
bt_string2uuid(&uuid, HDP_UUID);
if (bt_search_service(&src, &dst, &uuid, get_dcpsm_cb, dcpsm_data,
- free_dcpsm_data)) {
+ free_dcpsm_data) < 0) {
g_set_error(err, HDP_ERROR, HDP_CONNECTION_ERROR,
"Can't get remote SDP record");
g_free(dcpsm_data);
static void hdp_free_application(struct hdp_application *app)
{
- if (app->dbus_watcher)
+ if (app->dbus_watcher > 0)
g_dbus_remove_watch(app->conn, app->dbus_watcher);
- if (app->conn)
+ if (app->conn != NULL)
dbus_connection_unref(app->conn);
g_free(app->oname);
g_free(app->description);
struct hdp_application *hdp_application_ref(struct hdp_application *app)
{
- if (!app)
+ if (app == NULL)
return NULL;
app->ref++;
void hdp_application_unref(struct hdp_application *app)
{
- if (!app)
+ if (app == NULL)
return;
- app->ref --;
+ app->ref--;
DBG("health_application_unref(%p): ref=%d", app, app->ref);
if (app->ref > 0)