diff --git a/health/hdp.c b/health/hdp.c
index 403d4c8..6d53439 100644
--- a/health/hdp.c
+++ b/health/hdp.c
static struct hdp_channel *hdp_channel_ref(struct hdp_channel *chan)
{
- if (!chan)
+ if (chan == NULL)
return NULL;
chan->ref++;
static void hdp_channel_unref(struct hdp_channel *chan)
{
- if (!chan)
+ if (chan == NULL)
return;
chan->ref --;
do {
GSList *l = g_slist_find_custom(applications, &id, cmp_app_id);
- if (!l) {
+ if (l == NULL) {
next_app_id = (id % HDP_MDEP_FINAL) + 1;
return id;
} else
static gboolean set_app_path(struct hdp_application *app)
{
app->id = get_app_id();
- if (!app->id)
+ if (app->id == 0)
return FALSE;
app->path = g_strdup_printf(MANAGER_PATH "/health_app_%d", app->id);
static void device_unref_mcl(struct hdp_device *hdp_device)
{
- if (!hdp_device->mcl)
+ if (hdp_device->mcl == NULL)
return;
mcap_close_mcl(hdp_device->mcl, FALSE);
static void free_health_device(struct hdp_device *device)
{
- if (device->conn) {
+ if (device->conn != NULL) {
dbus_connection_unref(device->conn);
device->conn = NULL;
}
- if (device->dev) {
+ if (device->dev != NULL) {
btd_device_unref(device->dev);
device->dev = NULL;
}
dbus_message_iter_init(msg, &iter);
app = hdp_get_app_config(&iter, &err);
- if (err) {
+ if (err != NULL) {
g_error_free(err);
return btd_error_invalid_args(msg);
}
name = dbus_message_get_sender(msg);
- if (!name) {
+ if (name == NULL) {
hdp_application_unref(app);
return g_dbus_create_error(msg,
ERROR_INTERFACE ".HealthError",
l = g_slist_find_custom(applications, path, cmp_app);
- if (!l)
+ if (l == NULL)
return g_dbus_create_error(msg,
ERROR_INTERFACE ".InvalidArguments",
"Invalid arguments in method call, "
char *type;
reply = dbus_message_new_method_return(msg);
- if (!reply)
+ if (reply == NULL)
return NULL;
dbus_message_iter_init_append(reply, &iter);
static void abort_mdl_cb(GError *err, gpointer data)
{
- if (err)
+ if (err != NULL)
error("Aborting error: %s", err->message);
}
DBusMessage *reply;
int fd;
- if (err) {
+ if (err != NULL) {
struct hdp_channel *chan = dc_data->hdp_chann;
GError *gerr = NULL;
GError *gerr = NULL;
uint8_t mode;
- if (err) {
+ if (err != NULL) {
hdp_conn->cb(hdp_chann->mdl, err, hdp_conn);
return;
}
GError *gerr = NULL;
DBusMessage *reply;
- if (err) {
+ if (err != NULL) {
reply = g_dbus_create_error(dc_data->msg,
ERROR_INTERFACE ".HealthError",
"Cannot reconnect: %s", err->message);
GError *gerr = NULL;
int fd;
- if (err) {
+ if (err != NULL) {
return g_dbus_create_error(data->msg,
ERROR_INTERFACE ".HealthError",
"%s", err->message);
reply = channel_acquire_continue(data, err);
- if (reply)
+ if (reply != NULL)
g_dbus_send_message(dc_data->conn, reply);
}
static void free_echo_data(struct hdp_echo_data *edata)
{
- if (!edata)
+ if (edata == NULL)
return;
- if (edata->tid)
+ if (edata->tid > 0)
g_source_remove(edata->tid);
- if (edata->buf)
+ if (edata->buf != NULL)
g_free(edata->buf);
struct hdp_device *dev = hdp_chan->dev;
DBG("Destroy Health Channel %s", hdp_chan->path);
- if (!g_slist_find(dev->channels, hdp_chan))
+ if (g_slist_find(dev->channels, hdp_chan) == NULL)
goto end;
dev->channels = g_slist_remove(dev->channels, hdp_chan);
{
struct hdp_channel *hdp_chann;
- if (!dev)
+ if (dev == NULL)
return NULL;
hdp_chann = g_new0(struct hdp_channel, 1);
hdp_chann->dev = health_device_ref(dev);
hdp_chann->mdlid = mdlid;
- if (mdl)
+ if (mdl != NULL)
hdp_chann->mdl = mcap_mdl_ref(mdl);
- if (app) {
+ if (app != NULL) {
hdp_chann->mdep = app->id;
hdp_chann->app = hdp_application_ref(app);
} else
struct hdp_channel *chan;
char *path;
- while (dev->channels) {
+ while (dev->channels != NULL) {
chan = dev->channels->data;
path = g_strdup(chan->path);
static void close_device_con(struct hdp_device *dev, gboolean cache)
{
- if (!dev->mcl)
+ if (dev->mcl == NULL)
return;
mcap_close_mcl(dev->mcl, cache);
DBG("MDL imtu %d omtu %d Channel imtu %d omtu %d", imtu, omtu,
chan->imtu, chan->omtu);
- if (!chan->imtu)
+ if (chan->imtu == 0)
chan->imtu = imtu;
- if (!chan->omtu)
+ if (chan->omtu == 0)
chan->omtu = omtu;
if (chan->imtu != imtu || chan->omtu != omtu)
struct hdp_channel *chan;
DBG("hdp_mcap_mdl_connected_cb");
- if (!dev->ndc)
+ if (dev->ndc == NULL)
return;
chan = dev->ndc;
- if (!chan->mdl)
+ if (chan->mdl == NULL)
chan->mdl = mcap_mdl_ref(mdl);
- if (!g_slist_find(dev->channels, chan))
+ if (g_slist_find(dev->channels, chan) == NULL)
dev->channels = g_slist_prepend(dev->channels,
hdp_channel_ref(chan));
DBUS_TYPE_OBJECT_PATH, &chan->path,
DBUS_TYPE_INVALID);
- if (dev->fr)
+ if (dev->fr != NULL)
goto end;
dev->fr = hdp_channel_ref(chan);
DBG("hdp_mcap_mdl_deleted_cb");
l = g_slist_find_custom(dev->channels, mdl, cmp_chan_mdl);
- if (!l)
+ if (l == NULL)
return;
chan = l->data;
struct hdp_device *dev = data;
DBG("hdp_mcap_mdl_aborted_cb");
- if (!dev->ndc)
+ if (dev->ndc == NULL)
return;
dev->ndc->mdl = mcap_mdl_ref(mdl);
- if (!g_slist_find(dev->channels, dev->ndc))
+ if (g_slist_find(dev->channels, dev->ndc) == NULL)
dev->channels = g_slist_prepend(dev->channels,
hdp_channel_ref(dev->ndc));
}
dev->ndc = create_channel(dev, *conf, NULL, mdlid, NULL, NULL);
- if (!dev->ndc)
+ if (dev->ndc == NULL)
return MCAP_MDL_BUSY;
return MCAP_SUCCESS;
}
l = g_slist_find_custom(applications, &mdepid, cmp_app_id);
- if (!l)
+ if (l == NULL)
return MCAP_INVALID_MDEP;
app = l->data;
}
l = g_slist_find_custom(dev->channels, &mdlid, cmp_chan_mdlid);
- if (l) {
+ if (l != NULL) {
struct hdp_channel *chan = l->data;
char *path;
}
dev->ndc = create_channel(dev, *conf, NULL, mdlid, app, NULL);
- if (!dev->ndc)
+ if (dev->ndc == NULL)
return MCAP_MDL_BUSY;
return MCAP_SUCCESS;
GSList *l;
l = g_slist_find_custom(dev->channels, mdl, cmp_chan_mdl);
- if (!l)
+ if (l == NULL)
return MCAP_INVALID_MDL;
chan = l->data;
- if (!dev->fr && (chan->config != HDP_RELIABLE_DC) &&
- (chan->mdep != HDP_MDEP_ECHO))
+ if (dev->fr == NULL && chan->config != HDP_RELIABLE_DC &&
+ chan->mdep != HDP_MDEP_ECHO)
return MCAP_UNSPECIFIED_ERROR;
if (!mcap_set_data_chan_mode(dev->hdp_adapter->mi,
{
gboolean ret;
- if (!device->mcl)
+ if (device->mcl == NULL)
return FALSE;
ret = mcap_mcl_set_cb(device->mcl, device, err,
mcap_mcl_get_addr(mcl, &addr);
l = g_slist_find_custom(devices, &addr, cmp_dev_addr);
- if (!l) {
+ if (l == NULL) {
struct hdp_adapter *hdp_adapter = data;
struct btd_device *device;
char str[18];
GSList *l;
l = g_slist_find_custom(devices, mcl, cmp_dev_mcl);
- if (!l)
+ if (l == NULL)
return;
hdp_device = l->data;
GSList *l;
l = g_slist_find_custom(devices, mcl, cmp_dev_mcl);
- if (!l)
+ if (l == NULL)
return;
hdp_device = l->data;
GSList *l;
l = g_slist_find_custom(devices, mcl, cmp_dev_mcl);
- if (!l)
+ if (l == NULL)
return;
hdp_device = l->data;
static void release_adapter_instance(struct hdp_adapter *hdp_adapter)
{
- if (!hdp_adapter->mi)
+ if (hdp_adapter->mi == NULL)
return;
check_devices_mcl();
GError *err = NULL;
bdaddr_t addr;
- if (!applications) {
+ if (applications == NULL) {
release_adapter_instance(hdp_adapter);
goto update;
}
- if (hdp_adapter->mi)
+ if (hdp_adapter->mi != NULL)
goto update;
adapter_get_address(hdp_adapter->btd_adapter, &addr);
NULL, /* CSP is not used by now */
hdp_adapter, &err);
- if (!hdp_adapter->mi) {
+ if (hdp_adapter->mi == NULL) {
error("Error creating the MCAP instance: %s", err->message);
g_error_free(err);
return FALSE;
}
hdp_adapter->ccpsm = mcap_get_ctrl_psm(hdp_adapter->mi, &err);
- if (err) {
+ if (err != NULL) {
error("Error getting MCAP control PSM: %s", err->message);
goto fail;
}
hdp_adapter->dcpsm = mcap_get_data_psm(hdp_adapter->mi, &err);
- if (err) {
+ if (err != NULL) {
error("Error getting MCAP data PSM: %s", err->message);
goto fail;
}
fail:
release_adapter_instance(hdp_adapter);
- if (err)
+ if (err != NULL)
g_error_free(err);
+
return FALSE;
}
l = g_slist_find_custom(adapters, adapter, cmp_adapter);
- if (!l)
+ if (l == NULL)
return;
hdp_adapter = l->data;
adapters = g_slist_remove(adapters, hdp_adapter);
- if (hdp_adapter->sdp_handler)
+ if (hdp_adapter->sdp_handler > 0)
remove_record_from_server(hdp_adapter->sdp_handler);
release_adapter_instance(hdp_adapter);
btd_adapter_unref(hdp_adapter->btd_adapter);
static void delete_echo_channel_cb(GError *err, gpointer chan)
{
- if (err && err->code != MCAP_INVALID_MDL) {
+ if (err != NULL && err->code != MCAP_INVALID_MDL) {
/* TODO: Decide if more action is required here */
error("Error deleting echo channel: %s", err->message);
return;
{
struct hdp_channel *chan = data;
- if (err && err->code != MCAP_ERROR_INVALID_OPERATION) {
+ if (err != NULL && err->code != MCAP_ERROR_INVALID_OPERATION) {
error("Aborting error: %s", err->message);
if (err->code == MCAP_INVALID_MDL) {
/* MDL is removed from MCAP so we can */
GIOChannel *io;
int fd;
- if (err) {
+ if (err != NULL) {
reply = g_dbus_create_error(hdp_conn->msg,
ERROR_INTERFACE ".HealthError",
"%s", err->message);
g_io_add_watch(io, G_IO_ERR | G_IO_HUP | G_IO_NVAL | G_IO_IN,
check_echo, hdp_tmp_dc_data_ref(hdp_conn));
- edata->tid = g_timeout_add_seconds_full(G_PRIORITY_DEFAULT,
+ edata->tid = g_timeout_add_seconds_full(G_PRIORITY_DEFAULT,
ECHO_TIMEOUT, echo_timeout,
hdp_channel_ref(hdp_conn->hdp_chann),
(GDestroyNotify) hdp_channel_unref);
static void delete_mdl_cb(GError *err, gpointer data)
{
- if (err)
+ if (err != NULL)
error("Deleting error: %s", err->message);
}
struct mcap_mdl *mdl = data;
GError *gerr = NULL;
- if (err) {
+ if (err != NULL) {
error("%s", err->message);
if (err->code == MCAP_INVALID_MDL) {
/* MDL is removed from MCAP so we don't */
DBusMessage *reply;
GError *gerr = NULL;
- if (err) {
+ if (err != NULL) {
error("%s", err->message);
reply = g_dbus_create_reply(hdp_conn->msg,
DBUS_TYPE_OBJECT_PATH, &hdp_chann->path,
return;
}
- if (dev->fr)
+ if (dev->fr != NULL)
return;
dev->fr = hdp_channel_ref(hdp_chann);
GError *gerr = NULL;
DBusMessage *reply;
- if (err) {
+ if (err != NULL) {
reply = g_dbus_create_error(user_data->msg,
ERROR_INTERFACE ".HealthError",
"%s", err->message);
if (user_data->mdep != HDP_MDEP_ECHO &&
user_data->config == HDP_NO_PREFERENCE_DC) {
- if (!user_data->dev->fr && (conf != HDP_RELIABLE_DC)) {
+ if (user_data->dev->fr == NULL && conf != HDP_RELIABLE_DC) {
g_set_error(&gerr, HDP_ERROR, HDP_CONNECTION_ERROR,
"Data channel aborted, first data "
"channel should be reliable");
hdp_chan = create_channel(user_data->dev, conf, mdl,
mcap_mdl_get_mdlid(mdl),
user_data->app, &gerr);
- if (!hdp_chan)
+ if (hdp_chan == NULL)
goto fail;
if (user_data->mdep != HDP_MDEP_ECHO)
DBusMessage *reply;
GError *gerr = NULL;
- if (err) {
+ if (err != NULL) {
reply = g_dbus_create_error(data->msg,
ERROR_INTERFACE ".HealthError",
"%s", err->message);
return;
}
- if (!data->dev->mcl) {
+ if (data->dev->mcl == NULL) {
g_set_error(&gerr, HDP_ERROR, HDP_CONNECTION_ERROR,
"Mcl was closed");
goto fail;
data->cb = hdp_echo_connect_cb;
hdp_create_data_ref(data);
- if (device->mcl_conn && device->mcl) {
+ if (device->mcl_conn && device->mcl != NULL) {
if (mcap_create_mdl(device->mcl, data->mdep, data->config,
device_create_mdl_cb, data,
destroy_create_dc_data, &err))
DBusMessage *reply;
GError *gerr = NULL;
- if (err) {
+ if (err != NULL) {
reply = g_dbus_create_error(user_data->msg,
ERROR_INTERFACE ".HealthError",
"%s", err->message);
return btd_error_invalid_args(msg);
l = g_slist_find_custom(applications, app_path, cmp_app);
- if (!l)
+ if (l == NULL)
return btd_error_invalid_args(msg);
app = l->data;
DBusMessage *reply;
char *path;
- if (err && err->code != MCAP_INVALID_MDL) {
+ if (err != NULL && err->code != MCAP_INVALID_MDL) {
reply = g_dbus_create_error(del_data->msg,
ERROR_INTERFACE ".HealthError",
"%s", err->message);
GError *gerr = NULL;
DBusMessage *reply;
- if (err) {
+ if (err != NULL) {
reply = g_dbus_create_error(del_data->msg,
ERROR_INTERFACE ".HealthError",
"%s", err->message);
}
l = g_slist_find_custom(device->channels, path, cmp_chan_path);
- if (!l)
+ if (l == NULL)
return btd_error_invalid_args(msg);
hdp_chan = l->data;
char *path;
reply = dbus_message_new_method_return(msg);
- if (!reply)
+ if (reply == NULL)
return NULL;
dbus_message_iter_init_append(reply, &iter);
DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
- if (device->fr)
+ if (device->fr != NULL)
path = g_strdup(device->fr->path);
else
path = g_strdup("");
device_get_path(device->dev));
remove_channels(device);
- if (device->ndc) {
+ if (device->ndc != NULL) {
hdp_channel_unref(device->ndc);
device->ndc = NULL;
}
struct hdp_device *dev;
GSList *l;
- if (!device)
+ if (device == NULL)
return NULL;
dev = g_new0(struct hdp_device, 1);
health_device_ref(dev);
l = g_slist_find_custom(adapters, adapter, cmp_adapter);
- if (!l)
+ if (l == NULL)
goto fail;
dev->hdp_adapter = l->data;
GSList *l;
l = g_slist_find_custom(devices, device, cmp_device);
- if (l) {
+ if (l != NULL) {
hdev = l->data;
hdev->sdp_present = TRUE;
return 0;
}
hdev = create_health_device(conn, device);
- if (!hdev)
+ if (hdev == NULL)
return -1;
hdev->sdp_present = TRUE;
GSList *l;
l = g_slist_find_custom(devices, device, cmp_device);
- if (!l)
+ if (l == NULL)
return;
hdp_dev = l->data;