2014-06-24 12:07:40

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 1/7] HDP: Remove extra debug statements

From: Andrei Emeltchenko <[email protected]>

DBG() includes function name by default, so including it is not needed.
---
profiles/health/hdp.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/profiles/health/hdp.c b/profiles/health/hdp.c
index 4f90380..65800fa 100644
--- a/profiles/health/hdp.c
+++ b/profiles/health/hdp.c
@@ -91,7 +91,7 @@ static struct hdp_channel *hdp_channel_ref(struct hdp_channel *chan)

chan->ref++;

- DBG("health_channel_ref(%p): ref=%d", chan, chan->ref);
+ DBG("(%p): ref=%d", chan, chan->ref);
return chan;
}

@@ -115,7 +115,7 @@ static void hdp_channel_unref(struct hdp_channel *chan)
return;

chan->ref --;
- DBG("health_channel_unref(%p): ref=%d", chan, chan->ref);
+ DBG("(%p): ref=%d", chan, chan->ref);

if (chan->ref > 0)
return;
@@ -136,7 +136,7 @@ static struct hdp_create_dc *hdp_create_data_ref(struct hdp_create_dc *dc_data)
{
dc_data->ref++;

- DBG("hdp_create_data_ref(%p): ref=%d", dc_data, dc_data->ref);
+ DBG("(%p): ref=%d", dc_data, dc_data->ref);

return dc_data;
}
@@ -145,7 +145,7 @@ static void hdp_create_data_unref(struct hdp_create_dc *dc_data)
{
dc_data->ref--;

- DBG("hdp_create_data_unref(%p): ref=%d", dc_data, dc_data->ref);
+ DBG("(%p): ref=%d", dc_data, dc_data->ref);

if (dc_data->ref > 0)
return;
@@ -993,7 +993,7 @@ static void hdp_mcap_mdl_closed_cb(struct mcap_mdl *mdl, void *data)
{
/* struct hdp_device *dev = data; */

- DBG("hdp_mcap_mdl_closed_cb");
+ DBG("");

/* Nothing to do */
}
@@ -1005,7 +1005,8 @@ static void hdp_mcap_mdl_deleted_cb(struct mcap_mdl *mdl, void *data)
char *path;
GSList *l;

- DBG("hdp_mcap_mdl_deleted_cb");
+ DBG("");
+
l = g_slist_find_custom(dev->channels, mdl, cmp_chan_mdl);
if (l == NULL)
return;
@@ -1023,7 +1024,8 @@ static void hdp_mcap_mdl_aborted_cb(struct mcap_mdl *mdl, void *data)
{
struct hdp_device *dev = data;

- DBG("hdp_mcap_mdl_aborted_cb");
+ DBG("");
+
if (dev->ndc == NULL)
return;

@@ -2232,7 +2234,7 @@ struct hdp_device *health_device_ref(struct hdp_device *hdp_dev)
{
hdp_dev->ref++;

- DBG("health_device_ref(%p): ref=%d", hdp_dev, hdp_dev->ref);
+ DBG("(%p): ref=%d", hdp_dev, hdp_dev->ref);

return hdp_dev;
}
@@ -2241,7 +2243,7 @@ void health_device_unref(struct hdp_device *hdp_dev)
{
hdp_dev->ref--;

- DBG("health_device_unref(%p): ref=%d", hdp_dev, hdp_dev->ref);
+ DBG("(%p): ref=%d", hdp_dev, hdp_dev->ref);

if (hdp_dev->ref > 0)
return;
--
1.8.3.2



2014-06-25 09:27:08

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH 1/7] HDP: Remove extra debug statements

Hi Andrei,

On Tue, Jun 24, 2014, Andrei Emeltchenko wrote:
> DBG() includes function name by default, so including it is not needed.
> ---
> profiles/health/hdp.c | 20 +++++++++++---------
> 1 file changed, 11 insertions(+), 9 deletions(-)

All patches in this set have been applied. Thanks.

Johan

2014-06-24 12:07:44

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 5/7] HDP: Fix possible memory leak

From: Andrei Emeltchenko <[email protected]>

---
profiles/health/hdp_util.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/profiles/health/hdp_util.c b/profiles/health/hdp_util.c
index 5676eee..e3e0830 100644
--- a/profiles/health/hdp_util.c
+++ b/profiles/health/hdp_util.c
@@ -598,6 +598,13 @@ fail:
return NULL;
}

+static void free_hdp_list(void *list)
+{
+ sdp_list_t *hdp_list = list;
+
+ sdp_list_free(hdp_list, (sdp_free_func_t)sdp_data_free);
+}
+
static gboolean register_features(struct hdp_application *app,
sdp_list_t **sup_features)
{
@@ -620,16 +627,11 @@ static gboolean register_features(struct hdp_application *app,
fail:
if (hdp_feature != NULL)
sdp_list_free(hdp_feature, (sdp_free_func_t)sdp_data_free);
+ if (*sup_features != NULL)
+ sdp_list_free(*sup_features, free_hdp_list);
return FALSE;
}

-static void free_hdp_list(void *list)
-{
- sdp_list_t *hdp_list = list;
-
- sdp_list_free(hdp_list, (sdp_free_func_t)sdp_data_free);
-}
-
static gboolean register_service_sup_features(GSList *app_list,
sdp_record_t *sdp_record)
{
--
1.8.3.2


2014-06-24 12:07:43

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 4/7] mcap: Fix possible overflow

From: Andrei Emeltchenko <[email protected]>

---
profiles/health/mcap_sync.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/profiles/health/mcap_sync.c b/profiles/health/mcap_sync.c
index cc89d47..a0cc02a 100644
--- a/profiles/health/mcap_sync.c
+++ b/profiles/health/mcap_sync.c
@@ -187,7 +187,7 @@ void mcap_sync_stop(struct mcap_mcl *mcl)

static uint64_t time_us(struct timespec *tv)
{
- return tv->tv_sec * 1000000 + tv->tv_nsec / 1000;
+ return tv->tv_sec * 1000000ll + tv->tv_nsec / 1000ll;
}

static int64_t bt2us(int bt)
--
1.8.3.2


2014-06-24 12:07:46

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 7/7] HDP: Fix NULL check

From: Andrei Emeltchenko <[email protected]>

Improves readability of the code using similar check for not NULL.
---
profiles/health/hdp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/profiles/health/hdp.c b/profiles/health/hdp.c
index eaf3e46..54aca9d 100644
--- a/profiles/health/hdp.c
+++ b/profiles/health/hdp.c
@@ -1849,7 +1849,7 @@ static DBusMessage *device_echo(DBusConnection *conn,
data->cb = hdp_echo_connect_cb;
hdp_create_data_ref(data);

- if (device->mcl_conn && device->mcl != NULL) {
+ if (device->mcl_conn && device->mcl) {
if (mcap_create_mdl(device->mcl, data->mdep, data->config,
device_create_mdl_cb, data,
destroy_create_dc_data, &err))
--
1.8.3.2


2014-06-24 12:07:45

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 6/7] HDP: trivial: Remove empty lines

From: Andrei Emeltchenko <[email protected]>

---
profiles/health/hdp.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/profiles/health/hdp.c b/profiles/health/hdp.c
index 65800fa..eaf3e46 100644
--- a/profiles/health/hdp.c
+++ b/profiles/health/hdp.c
@@ -1193,7 +1193,6 @@ gboolean hdp_set_mcl_cb(struct hdp_device *device, GError **err)
MCAP_MDL_CB_REMOTE_CONN_REQ, hdp_mcap_mdl_conn_req_cb,
MCAP_MDL_CB_REMOTE_RECONN_REQ, hdp_mcap_mdl_reconn_req_cb,
MCAP_MDL_CB_INVALID);
-
if (ret)
return TRUE;

@@ -1350,7 +1349,6 @@ static gboolean update_adapter(struct hdp_adapter *hdp_adapter)
mcl_disconnected, mcl_uncached,
NULL, /* CSP is not used by now */
hdp_adapter, &err);
-
if (hdp_adapter->mi == NULL) {
error("Error creating the MCAP instance: %s", err->message);
g_error_free(err);
--
1.8.3.2


2014-06-24 12:07:42

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 3/7] HDP: Fix checking always constant error code

From: Andrei Emeltchenko <[email protected]>

Function sdp_set_add_access_protos() always returns 0, so there is no
sense to check for error code.
---
profiles/health/hdp_util.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/profiles/health/hdp_util.c b/profiles/health/hdp_util.c
index 75ae439..5676eee 100644
--- a/profiles/health/hdp_util.c
+++ b/profiles/health/hdp_util.c
@@ -473,7 +473,7 @@ static gboolean register_service_additional_protocols(
struct hdp_adapter *adapter,
sdp_record_t *sdp_record)
{
- gboolean ret;
+ gboolean ret = TRUE;
uuid_t l2cap_uuid, mcap_d_uuid;
sdp_list_t *l2cap_list, *proto_list = NULL, *mcap_list = NULL;
sdp_list_t *access_proto_list = NULL;
@@ -524,10 +524,7 @@ static gboolean register_service_additional_protocols(
goto end;
}

- if (sdp_set_add_access_protos(sdp_record, access_proto_list) < 0)
- ret = FALSE;
- else
- ret = TRUE;
+ sdp_set_add_access_protos(sdp_record, access_proto_list);

end:
if (l2cap_list != NULL)
--
1.8.3.2


2014-06-24 12:07:41

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 2/7] HDP: Fix checking always constant error code

From: Andrei Emeltchenko <[email protected]>

sdp_set_access_protos() always returns 0, there is no sense to check for
error code. Fixes compile warnings.
---
profiles/health/hdp_util.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/profiles/health/hdp_util.c b/profiles/health/hdp_util.c
index 47c464e..75ae439 100644
--- a/profiles/health/hdp_util.c
+++ b/profiles/health/hdp_util.c
@@ -425,11 +425,8 @@ static gboolean register_service_protocols(struct hdp_adapter *adapter,
goto end;
}

- if (sdp_set_access_protos(sdp_record, access_proto_list) < 0) {
- ret = FALSE;
- goto end;
- }
ret = TRUE;
+ sdp_set_access_protos(sdp_record, access_proto_list);

end:
if (l2cap_list != NULL)
--
1.8.3.2