2011-12-02 10:56:31

by Santiago Carot

[permalink] [raw]
Subject: Health Device Profile patches

This is a set of changes which fix some coding style issues in HDP and
some small bugs I've seen reviewing the code.

[PATCH 1/5] hdp_util: Fix coding style issues
[PATCH 2/5] hdp_types: Fix unappropiated field type for dbus watcher
[PATCH 3/5] hdp_util: Fix potential NULL pointer dereference
[PATCH 4/5] hdp_manager: Fix coding style issues
[PATCH 5/5] hdp: Fix coding style issues


2011-12-08 12:41:44

by Johan Hedberg

[permalink] [raw]
Subject: Re: Health Device Profile patches

Hi Santiago,

On Fri, Dec 02, 2011, Santiago Carot-Nemesio wrote:
> This is a set of changes which fix some coding style issues in HDP and
> some small bugs I've seen reviewing the code.
>
> [PATCH 1/5] hdp_util: Fix coding style issues
> [PATCH 2/5] hdp_types: Fix unappropiated field type for dbus watcher
> [PATCH 3/5] hdp_util: Fix potential NULL pointer dereference
> [PATCH 4/5] hdp_manager: Fix coding style issues
> [PATCH 5/5] hdp: Fix coding style issues

All five patches have been applied. Thanks.

Johan

2011-12-02 11:54:20

by Andrei Emeltchenko

[permalink] [raw]
Subject: Re: [PATCH 1/5] hdp_util: Fix coding style issues

He All,

On Fri, Dec 02, 2011 at 11:56:32AM +0100, Santiago Carot-Nemesio wrote:
> ---
> health/hdp_util.c | 171 +++++++++++++++++++++++++++--------------------------
> 1 files changed, 86 insertions(+), 85 deletions(-)
>
> 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
> @@ -362,24 +362,24 @@ static gboolean register_service_protocols(struct hdp_adapter *adapter,
> /* 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) {

Is this a really better way?

Best regards
Andrei Emeltchenko

2011-12-02 10:56:36

by Santiago Carot

[permalink] [raw]
Subject: [PATCH 5/5] hdp: Fix coding style issues

---
health/hdp.c | 167 +++++++++++++++++++++++++++++-----------------------------
1 files changed, 84 insertions(+), 83 deletions(-)

diff --git a/health/hdp.c b/health/hdp.c
index d167ab0..7fda9b1 100644
--- a/health/hdp.c
+++ b/health/hdp.c
@@ -86,7 +86,7 @@ struct hdp_echo_data {

static struct hdp_channel *hdp_channel_ref(struct hdp_channel *chan)
{
- if (!chan)
+ if (chan == NULL)
return NULL;

chan->ref++;
@@ -111,7 +111,7 @@ static void free_health_channel(struct hdp_channel *chan)

static void hdp_channel_unref(struct hdp_channel *chan)
{
- if (!chan)
+ if (chan == NULL)
return;

chan->ref --;
@@ -264,7 +264,7 @@ static uint8_t get_app_id(void)
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
@@ -285,7 +285,7 @@ static int cmp_app(gconstpointer a, gconstpointer b)
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);

@@ -294,7 +294,7 @@ static gboolean set_app_path(struct hdp_application *app)

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);
@@ -305,12 +305,12 @@ static void device_unref_mcl(struct hdp_device *hdp_device)

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;
}
@@ -349,13 +349,13 @@ static DBusMessage *manager_create_application(DBusConnection *conn,

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",
@@ -397,7 +397,7 @@ static DBusMessage *manager_destroy_application(DBusConnection *conn,

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, "
@@ -437,7 +437,7 @@ static DBusMessage *channel_get_properties(DBusConnection *conn,
char *type;

reply = dbus_message_new_method_return(msg);
- if (!reply)
+ if (reply == NULL)
return NULL;

dbus_message_iter_init_append(reply, &iter);
@@ -476,7 +476,7 @@ static void hdp_tmp_dc_data_destroy(gpointer data)

static void abort_mdl_cb(GError *err, gpointer data)
{
- if (err)
+ if (err != NULL)
error("Aborting error: %s", err->message);
}

@@ -486,7 +486,7 @@ static void hdp_mdl_reconn_cb(struct mcap_mdl *mdl, GError *err, gpointer data)
DBusMessage *reply;
int fd;

- if (err) {
+ if (err != NULL) {
struct hdp_channel *chan = dc_data->hdp_chann;
GError *gerr = NULL;

@@ -533,7 +533,7 @@ static void hdp_get_dcpsm_cb(uint16_t dcpsm, gpointer user_data, GError *err)
GError *gerr = NULL;
uint8_t mode;

- if (err) {
+ if (err != NULL) {
hdp_conn->cb(hdp_chann->mdl, err, hdp_conn);
return;
}
@@ -561,7 +561,7 @@ static void device_reconnect_mdl_cb(struct mcap_mdl *mdl, GError *err,
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);
@@ -599,7 +599,7 @@ static DBusMessage *channel_acquire_continue(struct hdp_tmp_dc_data *data,
GError *gerr = NULL;
int fd;

- if (err) {
+ if (err != NULL) {
return g_dbus_create_error(data->msg,
ERROR_INTERFACE ".HealthError",
"%s", err->message);
@@ -630,7 +630,7 @@ static void channel_acquire_cb(gpointer data, GError *err)

reply = channel_acquire_continue(data, err);

- if (reply)
+ if (reply != NULL)
g_dbus_send_message(dc_data->conn, reply);
}

@@ -690,13 +690,13 @@ static DBusMessage *channel_release(DBusConnection *conn,

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);


@@ -709,7 +709,7 @@ static void health_channel_destroy(void *data)
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);
@@ -752,7 +752,7 @@ static struct hdp_channel *create_channel(struct hdp_device *dev,
{
struct hdp_channel *hdp_chann;

- if (!dev)
+ if (dev == NULL)
return NULL;

hdp_chann = g_new0(struct hdp_channel, 1);
@@ -760,10 +760,10 @@ static struct hdp_channel *create_channel(struct hdp_device *dev,
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
@@ -797,7 +797,7 @@ static void remove_channels(struct hdp_device *dev)
struct hdp_channel *chan;
char *path;

- while (dev->channels) {
+ while (dev->channels != NULL) {
chan = dev->channels->data;

path = g_strdup(chan->path);
@@ -810,7 +810,7 @@ static void remove_channels(struct hdp_device *dev)

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);
@@ -917,9 +917,9 @@ static gboolean check_channel_conf(struct hdp_channel *chan)
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)
@@ -934,14 +934,14 @@ static void hdp_mcap_mdl_connected_cb(struct mcap_mdl *mdl, void *data)
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));

@@ -971,7 +971,7 @@ static void hdp_mcap_mdl_connected_cb(struct mcap_mdl *mdl, void *data)
DBUS_TYPE_OBJECT_PATH, &chan->path,
DBUS_TYPE_INVALID);

- if (dev->fr)
+ if (dev->fr != NULL)
goto end;

dev->fr = hdp_channel_ref(chan);
@@ -1003,7 +1003,7 @@ static void hdp_mcap_mdl_deleted_cb(struct mcap_mdl *mdl, void *data)

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;
@@ -1019,12 +1019,12 @@ static void hdp_mcap_mdl_aborted_cb(struct mcap_mdl *mdl, void *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));

@@ -1078,14 +1078,14 @@ static uint8_t hdp_mcap_mdl_conn_req_cb(struct mcap_mcl *mcl, uint8_t mdepid,
}

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;
@@ -1117,7 +1117,7 @@ static uint8_t hdp_mcap_mdl_conn_req_cb(struct mcap_mcl *mcl, uint8_t mdepid,
}

l = g_slist_find_custom(dev->channels, &mdlid, cmp_chan_mdlid);
- if (l) {
+ if (l != NULL) {
struct hdp_channel *chan = l->data;
char *path;

@@ -1134,7 +1134,7 @@ static uint8_t hdp_mcap_mdl_conn_req_cb(struct mcap_mcl *mcl, uint8_t mdepid,
}

dev->ndc = create_channel(dev, *conf, NULL, mdlid, app, NULL);
- if (!dev->ndc)
+ if (dev->ndc == NULL)
return MCAP_MDL_BUSY;

return MCAP_SUCCESS;
@@ -1148,13 +1148,13 @@ static uint8_t hdp_mcap_mdl_reconn_req_cb(struct mcap_mdl *mdl, void *data)
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,
@@ -1173,7 +1173,7 @@ gboolean hdp_set_mcl_cb(struct hdp_device *device, GError **err)
{
gboolean ret;

- if (!device->mcl)
+ if (device->mcl == NULL)
return FALSE;

ret = mcap_mcl_set_cb(device->mcl, device, err,
@@ -1202,7 +1202,7 @@ static void mcl_connected(struct mcap_mcl *mcl, gpointer data)

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];
@@ -1233,7 +1233,7 @@ static void mcl_reconnected(struct mcap_mcl *mcl, gpointer data)
GSList *l;

l = g_slist_find_custom(devices, mcl, cmp_dev_mcl);
- if (!l)
+ if (l == NULL)
return;

hdp_device = l->data;
@@ -1250,7 +1250,7 @@ static void mcl_disconnected(struct mcap_mcl *mcl, gpointer data)
GSList *l;

l = g_slist_find_custom(devices, mcl, cmp_dev_mcl);
- if (!l)
+ if (l == NULL)
return;

hdp_device = l->data;
@@ -1266,7 +1266,7 @@ static void mcl_uncached(struct mcap_mcl *mcl, gpointer data)
GSList *l;

l = g_slist_find_custom(devices, mcl, cmp_dev_mcl);
- if (!l)
+ if (l == NULL)
return;

hdp_device = l->data;
@@ -1311,7 +1311,7 @@ static void check_devices_mcl(void)

static void release_adapter_instance(struct hdp_adapter *hdp_adapter)
{
- if (!hdp_adapter->mi)
+ if (hdp_adapter->mi == NULL)
return;

check_devices_mcl();
@@ -1325,12 +1325,12 @@ static gboolean update_adapter(struct hdp_adapter *hdp_adapter)
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);
@@ -1340,20 +1340,20 @@ static gboolean update_adapter(struct hdp_adapter *hdp_adapter)
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;
}
@@ -1365,8 +1365,9 @@ update:

fail:
release_adapter_instance(hdp_adapter);
- if (err)
+ if (err != NULL)
g_error_free(err);
+
return FALSE;
}

@@ -1397,12 +1398,12 @@ void hdp_adapter_unregister(struct btd_adapter *adapter)

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);
@@ -1411,7 +1412,7 @@ void hdp_adapter_unregister(struct btd_adapter *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;
@@ -1445,7 +1446,7 @@ static void abort_echo_channel_cb(GError *err, gpointer data)
{
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 */
@@ -1554,7 +1555,7 @@ static void hdp_echo_connect_cb(struct mcap_mdl *mdl, GError *err,
GIOChannel *io;
int fd;

- if (err) {
+ if (err != NULL) {
reply = g_dbus_create_error(hdp_conn->msg,
ERROR_INTERFACE ".HealthError",
"%s", err->message);
@@ -1592,7 +1593,7 @@ static void hdp_echo_connect_cb(struct mcap_mdl *mdl, GError *err,
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);
@@ -1602,7 +1603,7 @@ static void hdp_echo_connect_cb(struct mcap_mdl *mdl, GError *err,

static void delete_mdl_cb(GError *err, gpointer data)
{
- if (err)
+ if (err != NULL)
error("Deleting error: %s", err->message);
}

@@ -1611,7 +1612,7 @@ static void abort_and_del_mdl_cb(GError *err, gpointer data)
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 */
@@ -1634,7 +1635,7 @@ static void hdp_mdl_conn_cb(struct mcap_mdl *mdl, GError *err, gpointer data)
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,
@@ -1661,7 +1662,7 @@ static void hdp_mdl_conn_cb(struct mcap_mdl *mdl, GError *err, gpointer data)
return;
}

- if (dev->fr)
+ if (dev->fr != NULL)
return;

dev->fr = hdp_channel_ref(hdp_chann);
@@ -1680,7 +1681,7 @@ static void device_create_mdl_cb(struct mcap_mdl *mdl, uint8_t conf,
GError *gerr = NULL;
DBusMessage *reply;

- if (err) {
+ if (err != NULL) {
reply = g_dbus_create_error(user_data->msg,
ERROR_INTERFACE ".HealthError",
"%s", err->message);
@@ -1690,7 +1691,7 @@ static void device_create_mdl_cb(struct mcap_mdl *mdl, uint8_t conf,

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");
@@ -1707,7 +1708,7 @@ static void device_create_mdl_cb(struct mcap_mdl *mdl, uint8_t conf,
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)
@@ -1771,7 +1772,7 @@ static void device_create_dc_cb(gpointer user_data, GError *err)
DBusMessage *reply;
GError *gerr = NULL;

- if (err) {
+ if (err != NULL) {
reply = g_dbus_create_error(data->msg,
ERROR_INTERFACE ".HealthError",
"%s", err->message);
@@ -1779,7 +1780,7 @@ static void device_create_dc_cb(gpointer user_data, GError *err)
return;
}

- if (!data->dev->mcl) {
+ if (data->dev->mcl == NULL) {
g_set_error(&gerr, HDP_ERROR, HDP_CONNECTION_ERROR,
"Mcl was closed");
goto fail;
@@ -1817,7 +1818,7 @@ static DBusMessage *device_echo(DBusConnection *conn,
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))
@@ -1843,7 +1844,7 @@ static void device_get_mdep_cb(uint8_t mdep, gpointer data, GError *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);
@@ -1890,7 +1891,7 @@ static DBusMessage *device_create_channel(DBusConnection *conn,
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;
@@ -1939,7 +1940,7 @@ static void hdp_mdl_delete_cb(GError *err, gpointer 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);
@@ -1961,7 +1962,7 @@ static void hdp_continue_del_cb(gpointer user_data, GError *err)
GError *gerr = NULL;
DBusMessage *reply;

- if (err) {
+ if (err != NULL) {
reply = g_dbus_create_error(del_data->msg,
ERROR_INTERFACE ".HealthError",
"%s", err->message);
@@ -1999,7 +2000,7 @@ static DBusMessage *device_destroy_channel(DBusConnection *conn,
}

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;
@@ -2038,7 +2039,7 @@ static DBusMessage *device_get_properties(DBusConnection *conn,
char *path;

reply = dbus_message_new_method_return(msg);
- if (!reply)
+ if (reply == NULL)
return NULL;

dbus_message_iter_init_append(reply, &iter);
@@ -2048,7 +2049,7 @@ static DBusMessage *device_get_properties(DBusConnection *conn,
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("");
@@ -2067,7 +2068,7 @@ static void health_device_destroy(void *data)
device_get_path(device->dev));

remove_channels(device);
- if (device->ndc) {
+ if (device->ndc != NULL) {
hdp_channel_unref(device->ndc);
device->ndc = NULL;
}
@@ -2102,7 +2103,7 @@ static struct hdp_device *create_health_device(DBusConnection *conn,
struct hdp_device *dev;
GSList *l;

- if (!device)
+ if (device == NULL)
return NULL;

dev = g_new0(struct hdp_device, 1);
@@ -2111,7 +2112,7 @@ static struct hdp_device *create_health_device(DBusConnection *conn,
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;
@@ -2139,14 +2140,14 @@ int hdp_device_register(DBusConnection *conn, struct btd_device *device)
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;
@@ -2162,7 +2163,7 @@ void hdp_device_unregister(struct btd_device *device)
GSList *l;

l = g_slist_find_custom(devices, device, cmp_device);
- if (!l)
+ if (l == NULL)
return;

hdp_dev = l->data;
--
1.7.7.4


2011-12-02 10:56:35

by Santiago Carot

[permalink] [raw]
Subject: [PATCH 4/5] hdp_manager: Fix coding style issues

---
health/hdp_manager.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/health/hdp_manager.c b/health/hdp_manager.c
index 60ccf55..b3c10a9 100644
--- a/health/hdp_manager.c
+++ b/health/hdp_manager.c
@@ -76,7 +76,7 @@ static struct btd_device_driver hdp_device_driver = {

int hdp_manager_init(DBusConnection *conn)
{
- if (hdp_manager_start(conn))
+ if (hdp_manager_start(conn) < 0)
return -1;

connection = dbus_connection_ref(conn);
--
1.7.7.4


2011-12-02 10:56:34

by Santiago Carot

[permalink] [raw]
Subject: [PATCH 3/5] hdp_util: Fix potential NULL pointer dereference

sdp_data_get can return NULL, we have to check the provided return
value before using it.
---
health/hdp_util.c | 11 +++++------
1 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/health/hdp_util.c b/health/hdp_util.c
index 7a234c1..4d546ad 100644
--- a/health/hdp_util.c
+++ b/health/hdp_util.c
@@ -758,9 +758,8 @@ static gboolean get_mdep_from_rec(const sdp_record_t *rec, uint8_t role,
return TRUE;

list = sdp_data_get(rec, SDP_ATTR_SUPPORTED_FEATURES_LIST);
-
- if (list->dtd != SDP_SEQ8 && list->dtd != SDP_SEQ16 &&
- list->dtd != SDP_SEQ32)
+ if (list == NULL || (list->dtd != SDP_SEQ8 && list->dtd != SDP_SEQ16 &&
+ list->dtd != SDP_SEQ32))
return FALSE;

for (feat = list->val.dataseq; feat; feat = feat->next) {
@@ -911,8 +910,8 @@ static gboolean hdp_get_prot_desc_list(const sdp_record_t *rec, guint16 *psm,
return TRUE;

pdl = sdp_data_get(rec, SDP_ATTR_PROTO_DESC_LIST);
- if (pdl->dtd != SDP_SEQ8 && pdl->dtd != SDP_SEQ16 &&
- pdl->dtd != SDP_SEQ32)
+ if (pdl == NULL || (pdl->dtd != SDP_SEQ8 && pdl->dtd != SDP_SEQ16 &&
+ pdl->dtd != SDP_SEQ32))
return FALSE;

p0 = pdl->val.dataseq;
@@ -935,7 +934,7 @@ static gboolean hdp_get_add_prot_desc_list(const sdp_record_t *rec,
return TRUE;

pdl = sdp_data_get(rec, SDP_ATTR_ADD_PROTO_DESC_LIST);
- if (pdl->dtd != SDP_SEQ8)
+ if (pdl == NULL || pdl->dtd != SDP_SEQ8)
return FALSE;
pdl = pdl->val.dataseq;
if (pdl->dtd != SDP_SEQ8)
--
1.7.7.4


2011-12-02 10:56:33

by Santiago Carot

[permalink] [raw]
Subject: [PATCH 2/5] hdp_types: Fix unappropiated field type for dbus watcher id

This value is provided by g_dbus_add_disconnect_watch wich provides
an unsigned type, not an integer one.
---
health/hdp_types.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/health/hdp_types.h b/health/hdp_types.h
index eecc138..9a6776f 100644
--- a/health/hdp_types.h
+++ b/health/hdp_types.h
@@ -81,7 +81,7 @@ struct hdp_application {
char *description; /* Options description for SDP record */
uint8_t id; /* The identification is also the mdepid */
char *oname; /* Name of the owner application */
- int dbus_watcher; /* Watch for clients disconnection */
+ guint dbus_watcher; /* Watch for clients disconnection */
gint ref; /* Reference counter */
};

--
1.7.7.4


2011-12-02 10:56:32

by Santiago Carot

[permalink] [raw]
Subject: [PATCH 1/5] hdp_util: Fix coding style issues

---
health/hdp_util.c | 171 +++++++++++++++++++++++++++--------------------------
1 files changed, 86 insertions(+), 85 deletions(-)

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
@@ -362,24 +362,24 @@ static gboolean register_service_protocols(struct hdp_adapter *adapter,
/* 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;
}
@@ -387,30 +387,30 @@ static gboolean register_service_protocols(struct hdp_adapter *adapter,
/* 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;
}
@@ -422,17 +422,17 @@ static gboolean register_service_protocols(struct hdp_adapter *adapter,
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;
@@ -448,7 +448,7 @@ static gboolean register_service_profiles(sdp_record_t *sdp_record)
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 */
@@ -475,24 +475,24 @@ static gboolean register_service_additional_protocols(
/* 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;
}
@@ -500,19 +500,19 @@ static gboolean register_service_additional_protocols(
/* 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;
}
@@ -523,15 +523,15 @@ static gboolean register_service_additional_protocols(
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;
@@ -546,49 +546,49 @@ static sdp_list_t *app_to_sdplist(struct hdp_application *app)
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;
@@ -600,21 +600,21 @@ static gboolean register_features(struct hdp_application *app,
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;
}
@@ -652,7 +652,7 @@ static gboolean register_data_exchange_spec(sdp_record_t *record)
/* 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) {
@@ -669,7 +669,7 @@ static gboolean register_mcap_features(sdp_record_t *sdp_record)
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,
@@ -686,19 +686,19 @@ gboolean hdp_update_sdp_record(struct hdp_adapter *adapter, GSList *app_list)
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 */
@@ -724,7 +724,7 @@ gboolean hdp_update_sdp_record(struct hdp_adapter *adapter, GSList *app_list)

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);
@@ -735,7 +735,7 @@ gboolean hdp_update_sdp_record(struct hdp_adapter *adapter, GSList *app_list)
return TRUE;

fail:
- if (sdp_record)
+ if (sdp_record != NULL)
sdp_record_free(sdp_record);
return FALSE;
}
@@ -754,7 +754,7 @@ static gboolean get_mdep_from_rec(const sdp_record_t *rec, uint8_t role,
{
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);
@@ -771,15 +771,15 @@ static gboolean get_mdep_from_rec(const sdp_record_t *rec, uint8_t role,
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;
@@ -792,10 +792,11 @@ static gboolean get_mdep_from_rec(const sdp_record_t *rec, uint8_t role,
!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);
@@ -812,7 +813,7 @@ static void get_mdep_cb(sdp_list_t *recs, int err, gpointer user_data)
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);
@@ -862,7 +863,7 @@ gboolean hdp_get_mdep(struct hdp_device *device, struct hdp_application *app,

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);
@@ -877,8 +878,8 @@ static gboolean get_prot_desc_entry(sdp_data_t *entry, int type, guint16 *val)
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;
@@ -889,7 +890,7 @@ static gboolean get_prot_desc_entry(sdp_data_t *entry, int type, guint16 *val)
if (proto != type)
return FALSE;

- if (!val)
+ if (val == NULL)
return TRUE;

iter = iter->next;
@@ -906,7 +907,7 @@ static gboolean hdp_get_prot_desc_list(const sdp_record_t *rec, guint16 *psm,
{
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);
@@ -930,7 +931,7 @@ static gboolean hdp_get_add_prot_desc_list(const sdp_record_t *rec,
{
sdp_data_t *pdl, *p0, *p1;

- if (!psm)
+ if (psm == NULL)
return TRUE;

pdl = sdp_data_get(rec, SDP_ATTR_ADD_PROTO_DESC_LIST);
@@ -981,7 +982,7 @@ static gboolean get_dcpsm(sdp_list_t *recs, uint16_t *dcpsm)

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)
@@ -1001,7 +1002,7 @@ static void destroy_con_mcl_data(gpointer data)

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++;
@@ -1014,19 +1015,19 @@ static void create_mcl_cb(struct mcap_mcl *mcl, GError *err, gpointer data)
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);
}

@@ -1037,13 +1038,13 @@ static void search_cb(sdp_list_t *recs, int err, gpointer user_data)
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;
@@ -1092,7 +1093,7 @@ gboolean hdp_establish_mcl(struct hdp_device *device,

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);
@@ -1108,7 +1109,7 @@ static void get_dcpsm_cb(sdp_list_t *recs, int err, gpointer 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;
@@ -1132,7 +1133,7 @@ static void free_dcpsm_data(gpointer data)
{
struct get_dcpsm_data *dcpsm_data = data;

- if (!dcpsm_data)
+ if (dcpsm_data == NULL)
return;

if (dcpsm_data->destroy)
@@ -1160,7 +1161,7 @@ gboolean hdp_get_dcpsm(struct hdp_device *device, hdp_continue_dcpsm_f func,

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);
@@ -1172,10 +1173,10 @@ gboolean hdp_get_dcpsm(struct hdp_device *device, hdp_continue_dcpsm_f func,

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);
@@ -1185,7 +1186,7 @@ static void hdp_free_application(struct hdp_application *app)

struct hdp_application *hdp_application_ref(struct hdp_application *app)
{
- if (!app)
+ if (app == NULL)
return NULL;

app->ref++;
@@ -1196,10 +1197,10 @@ struct hdp_application *hdp_application_ref(struct hdp_application *app)

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)
--
1.7.7.4