2014-03-21 19:20:30

by Claudio Takahasi

[permalink] [raw]
Subject: [PATCH BlueZ v0 1/4] gatt: Fix coding style when testing pointers

Use !ptr instead of ptr == NULL
---
src/gatt-dbus.c | 10 +++++-----
src/gatt.c | 8 ++++----
2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/gatt-dbus.c b/src/gatt-dbus.c
index 3c3b54c..896accf 100644
--- a/src/gatt-dbus.c
+++ b/src/gatt-dbus.c
@@ -284,7 +284,7 @@ static int register_external_service(const struct external_app *eapp,
if (bt_string_to_uuid(&uuid, str) < 0)
return -EINVAL;

- if (btd_gatt_add_service(&uuid) == NULL)
+ if (!btd_gatt_add_service(&uuid))
return -EINVAL;

return 0;
@@ -321,7 +321,7 @@ static int register_external_characteristics(GSList *proxies)

attr = btd_gatt_add_char(&uuid, 0x00, proxy_read_cb,
proxy_write_cb);
- if (attr == NULL)
+ if (!attr)
return -EINVAL;

path = g_dbus_proxy_get_path(proxy);
@@ -340,7 +340,7 @@ static void client_ready(GDBusClient *client, void *user_data)
DBusConnection *conn = btd_get_dbus_connection();
DBusMessage *reply;

- if (eapp->proxies == NULL)
+ if (!eapp->proxies)
goto fail;

proxy = eapp->proxies->data;
@@ -376,7 +376,7 @@ static struct external_app *new_external_app(DBusConnection *conn,
const char *sender = dbus_message_get_sender(msg);

client = g_dbus_client_new(conn, sender, "/");
- if (client == NULL)
+ if (!client)
return NULL;

eapp = g_new0(struct external_app, 1);
@@ -421,7 +421,7 @@ static DBusMessage *register_service(DBusConnection *conn,
return btd_error_already_exists(msg);

eapp = new_external_app(conn, msg, path);
- if (eapp == NULL)
+ if (!eapp)
return btd_error_failed(msg, "Not enough resources");

external_apps = g_slist_prepend(external_apps, eapp);
diff --git a/src/gatt.c b/src/gatt.c
index 45b5e26..92092d3 100644
--- a/src/gatt.c
+++ b/src/gatt.c
@@ -77,7 +77,7 @@ static struct btd_attribute *new_const_attribute(const bt_uuid_t *type,
struct btd_attribute *attr;

attr = malloc0(sizeof(struct btd_attribute) + len);
- if (attr == NULL)
+ if (!attr)
return NULL;

attr->type = *type;
@@ -118,7 +118,7 @@ struct btd_attribute *btd_gatt_add_service(const bt_uuid_t *uuid)
put_uuid_le(uuid, value);

attr = new_const_attribute(&primary_uuid, value, len);
- if (attr == NULL)
+ if (!attr)
return NULL;

if (local_database_add(next_handle, attr) < 0) {
@@ -167,11 +167,11 @@ struct btd_attribute *btd_gatt_add_char(const bt_uuid_t *uuid,
put_uuid_le(uuid, &value[3]);

char_decl = new_const_attribute(&chr_uuid, value, len);
- if (char_decl == NULL)
+ if (!char_decl)
goto fail;

char_value = new0(struct btd_attribute, 1);
- if (char_value == NULL)
+ if (!char_value)
goto fail;

if (local_database_add(next_handle, char_decl) < 0)
--
1.8.3.1



2014-03-24 14:29:25

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH BlueZ v1 1/2] gatt: Fix coding style when testing pointers

Hi Claudio,

On Mon, Mar 24, 2014, Claudio Takahasi wrote:
> Use !ptr instead of ptr == NULL
> ---
> src/gatt-dbus.c | 10 +++++-----
> src/gatt.c | 8 ++++----
> 2 files changed, 9 insertions(+), 9 deletions(-)

Both patches have been applied. Thanks.

Johan

2014-03-24 14:06:41

by Claudio Takahasi

[permalink] [raw]
Subject: [PATCH BlueZ v1 2/2] tools: Fix coding style checking boolean

This patch fixes tools/gatt-service.c coding style, using !foo instead
of foo == FALSE.
---
tools/gatt-service.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/gatt-service.c b/tools/gatt-service.c
index 1e369d7..624b835 100644
--- a/tools/gatt-service.c
+++ b/tools/gatt-service.c
@@ -205,9 +205,9 @@ static char *register_service(const char *uuid)
char *path;

path = g_strdup_printf("/service%d", id++);
- if (g_dbus_register_interface(connection, path, GATT_SERVICE_IFACE,
+ if (!g_dbus_register_interface(connection, path, GATT_SERVICE_IFACE,
NULL, NULL, service_properties,
- g_strdup(uuid), g_free) == FALSE) {
+ g_strdup(uuid), g_free)) {
printf("Couldn't register service interface\n");
g_free(path);
return NULL;
@@ -285,7 +285,7 @@ static void register_external_service(gpointer a, gpointer b)

dbus_message_iter_close_container(&iter, &dict);

- if (g_dbus_send_message_with_reply(conn, msg, &call, -1) == FALSE) {
+ if (!g_dbus_send_message_with_reply(conn, msg, &call, -1)) {
dbus_message_unref(msg);
return;
}
--
1.8.3.1


2014-03-24 14:06:40

by Claudio Takahasi

[permalink] [raw]
Subject: [PATCH BlueZ v1 1/2] gatt: Fix coding style when testing pointers

Use !ptr instead of ptr == NULL
---
src/gatt-dbus.c | 10 +++++-----
src/gatt.c | 8 ++++----
2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/gatt-dbus.c b/src/gatt-dbus.c
index ff167c2..95d1243 100644
--- a/src/gatt-dbus.c
+++ b/src/gatt-dbus.c
@@ -286,7 +286,7 @@ static int register_external_service(const struct external_app *eapp,
if (bt_string_to_uuid(&uuid, str) < 0)
return -EINVAL;

- if (btd_gatt_add_service(&uuid) == NULL)
+ if (!btd_gatt_add_service(&uuid))
return -EINVAL;

return 0;
@@ -323,7 +323,7 @@ static int register_external_characteristics(GSList *proxies)

attr = btd_gatt_add_char(&uuid, 0x00, proxy_read_cb,
proxy_write_cb);
- if (attr == NULL)
+ if (!attr)
return -EINVAL;

path = g_dbus_proxy_get_path(proxy);
@@ -342,7 +342,7 @@ static void client_ready(GDBusClient *client, void *user_data)
DBusConnection *conn = btd_get_dbus_connection();
DBusMessage *reply;

- if (eapp->proxies == NULL)
+ if (!eapp->proxies)
goto fail;

proxy = eapp->proxies->data;
@@ -378,7 +378,7 @@ static struct external_app *new_external_app(DBusConnection *conn,
const char *sender = dbus_message_get_sender(msg);

client = g_dbus_client_new(conn, sender, "/");
- if (client == NULL)
+ if (!client)
return NULL;

eapp = g_new0(struct external_app, 1);
@@ -423,7 +423,7 @@ static DBusMessage *register_service(DBusConnection *conn,
return btd_error_already_exists(msg);

eapp = new_external_app(conn, msg, path);
- if (eapp == NULL)
+ if (!eapp)
return btd_error_failed(msg, "Not enough resources");

external_apps = g_slist_prepend(external_apps, eapp);
diff --git a/src/gatt.c b/src/gatt.c
index 45b5e26..92092d3 100644
--- a/src/gatt.c
+++ b/src/gatt.c
@@ -77,7 +77,7 @@ static struct btd_attribute *new_const_attribute(const bt_uuid_t *type,
struct btd_attribute *attr;

attr = malloc0(sizeof(struct btd_attribute) + len);
- if (attr == NULL)
+ if (!attr)
return NULL;

attr->type = *type;
@@ -118,7 +118,7 @@ struct btd_attribute *btd_gatt_add_service(const bt_uuid_t *uuid)
put_uuid_le(uuid, value);

attr = new_const_attribute(&primary_uuid, value, len);
- if (attr == NULL)
+ if (!attr)
return NULL;

if (local_database_add(next_handle, attr) < 0) {
@@ -167,11 +167,11 @@ struct btd_attribute *btd_gatt_add_char(const bt_uuid_t *uuid,
put_uuid_le(uuid, &value[3]);

char_decl = new_const_attribute(&chr_uuid, value, len);
- if (char_decl == NULL)
+ if (!char_decl)
goto fail;

char_value = new0(struct btd_attribute, 1);
- if (char_value == NULL)
+ if (!char_value)
goto fail;

if (local_database_add(next_handle, char_decl) < 0)
--
1.8.3.1


2014-03-24 13:40:02

by Claudio Takahasi

[permalink] [raw]
Subject: Re: [PATCH BlueZ v0 1/4] gatt: Fix coding style when testing pointers

Hi Johan:

On Mon, Mar 24, 2014 at 6:03 AM, Johan Hedberg <[email protected]> wrote:
> Hi Claudio,
>
> On Fri, Mar 21, 2014, Claudio Takahasi wrote:
>> Use !ptr instead of ptr == NULL
>> ---
>> src/gatt-dbus.c | 10 +++++-----
>> src/gatt.c | 8 ++++----
>> 2 files changed, 9 insertions(+), 9 deletions(-)
>
> I've applied patches 2 and 3 from this set. The other two didn't apply
> cleanly.
>
> Johan


I will re-send the patches again after "Add basic GATT
characteristics" gets integrated.

Regards,
Claudio

2014-03-24 09:03:41

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH BlueZ v0 1/4] gatt: Fix coding style when testing pointers

Hi Claudio,

On Fri, Mar 21, 2014, Claudio Takahasi wrote:
> Use !ptr instead of ptr == NULL
> ---
> src/gatt-dbus.c | 10 +++++-----
> src/gatt.c | 8 ++++----
> 2 files changed, 9 insertions(+), 9 deletions(-)

I've applied patches 2 and 3 from this set. The other two didn't apply
cleanly.

Johan

2014-03-21 19:20:33

by Claudio Takahasi

[permalink] [raw]
Subject: [PATCH BlueZ v0 4/4] tools: Fix coding style checking boolean

This patch fixes tools/gatt-service.c coding style, using !foo instead
of foo == FALSE.
---
tools/gatt-service.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/gatt-service.c b/tools/gatt-service.c
index 71f7a50..6933c05 100644
--- a/tools/gatt-service.c
+++ b/tools/gatt-service.c
@@ -205,9 +205,9 @@ static char *register_service(const char *uuid)
char *path;

path = g_strdup_printf("/service%d", id++);
- if (g_dbus_register_interface(connection, path, GATT_SERVICE_IFACE,
+ if (!g_dbus_register_interface(connection, path, GATT_SERVICE_IFACE,
NULL, NULL, service_properties,
- g_strdup(uuid), g_free) == FALSE) {
+ g_strdup(uuid), g_free)) {
printf("Couldn't register service interface\n");
g_free(path);
return NULL;
@@ -287,7 +287,7 @@ static void register_external_service(gpointer a, gpointer b)

dbus_message_iter_close_container(&iter, &dict);

- if (g_dbus_send_message_with_reply(conn, msg, &call, -1) == FALSE) {
+ if (!g_dbus_send_message_with_reply(conn, msg, &call, -1)) {
dbus_message_unref(msg);
return;
}
--
1.8.3.1


2014-03-21 19:20:32

by Claudio Takahasi

[permalink] [raw]
Subject: [PATCH BlueZ v0 3/4] tools: Fix coding style when testing pointer

This patch fixes tools/gatt-service.c coding style, using !ptr instead
of ptr == NULL.
---
tools/gatt-service.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/gatt-service.c b/tools/gatt-service.c
index 255f3bb..71f7a50 100644
--- a/tools/gatt-service.c
+++ b/tools/gatt-service.c
@@ -272,7 +272,7 @@ static void register_external_service(gpointer a, gpointer b)

msg = dbus_message_new_method_call("org.bluez", "/org/bluez",
GATT_MGR_IFACE, "RegisterService");
- if (msg == NULL) {
+ if (!msg) {
printf("Couldn't allocate D-Bus message\n");
return;
}
--
1.8.3.1


2014-03-21 19:20:31

by Claudio Takahasi

[permalink] [raw]
Subject: [PATCH BlueZ v0 2/4] gatt: Fix coding style checking boolean

Use !foo instead of foo == FALSE
---
src/gatt-dbus.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gatt-dbus.c b/src/gatt-dbus.c
index 896accf..ac50008 100644
--- a/src/gatt-dbus.c
+++ b/src/gatt-dbus.c
@@ -450,9 +450,9 @@ static const GDBusMethodTable methods[] = {

gboolean gatt_dbus_manager_register(void)
{
- if (g_dbus_register_interface(btd_get_dbus_connection(),
+ if (!g_dbus_register_interface(btd_get_dbus_connection(),
"/org/bluez", GATT_MGR_IFACE,
- methods, NULL, NULL, NULL, NULL) == FALSE)
+ methods, NULL, NULL, NULL, NULL))
return FALSE;

proxy_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal,
--
1.8.3.1