linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/6] gitignore: Ignore file generated by Automake 1.13
@ 2013-04-08 20:56 Lucas De Marchi
  2013-04-08 20:56 ` [PATCH v2 2/6] gdbus: Use gcc builtin instead of g_atomic Lucas De Marchi
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Lucas De Marchi @ 2013-04-08 20:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Lucas De Marchi

From: Lucas De Marchi <lucas.de.marchi@gmail.com>

Automake >= 1.13 enables parallel-tests option which uses a test-driver
script (copied by automake). Ignore this file.
---
 .gitignore | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/.gitignore b/.gitignore
index e306f68..c6e0ae2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,6 +25,8 @@ ltmain.sh
 missing
 stamp-h1
 autom4te.cache
+test-driver
+test-suite.log
 
 lib/bluez.pc
 lib/bluetooth
@@ -89,3 +91,5 @@ unit/test-gobex-apparam
 unit/test-gobex-header
 unit/test-gobex-packet
 unit/test-gobex-transfer
+unit/test-*.log
+unit/test-*.trs
-- 
1.8.2.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 2/6] gdbus: Use gcc builtin instead of g_atomic
  2013-04-08 20:56 [PATCH v2 1/6] gitignore: Ignore file generated by Automake 1.13 Lucas De Marchi
@ 2013-04-08 20:56 ` Lucas De Marchi
  2013-04-08 20:56 ` [PATCH v2 3/6] attrib: " Lucas De Marchi
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Lucas De Marchi @ 2013-04-08 20:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Lucas De Marchi

g_atomic_* end up using G_STATIC_ASSERT, causing gcc 4.8 to yell due to
-Wunused-local-typedefs.

gdbus/client.c: In function ‘g_dbus_client_ref’:
/usr/include/glib-2.0/glib/gmacros.h:162:53: error: typedef ‘_GStaticAssertCompileTimeAssertion_2’ locally defined but not used [-Werror=unused-local-typedefs]
 #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1]
---
 gdbus/client.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/gdbus/client.c b/gdbus/client.c
index 2a7d2e1..c2d2346 100644
--- a/gdbus/client.c
+++ b/gdbus/client.c
@@ -33,7 +33,7 @@
 #define METHOD_CALL_TIMEOUT (300 * 1000)
 
 struct GDBusClient {
-	gint ref_count;
+	int ref_count;
 	DBusConnection *dbus_conn;
 	char *service_name;
 	char *unique_name;
@@ -54,7 +54,7 @@ struct GDBusClient {
 };
 
 struct GDBusProxy {
-	gint ref_count;
+	int ref_count;
 	GDBusClient *client;
 	char *obj_path;
 	char *interface;
@@ -444,7 +444,7 @@ GDBusProxy *g_dbus_proxy_ref(GDBusProxy *proxy)
 	if (proxy == NULL)
 		return NULL;
 
-	g_atomic_int_inc(&proxy->ref_count);
+	__sync_fetch_and_add(&proxy->ref_count, 1);
 
 	return proxy;
 }
@@ -454,7 +454,7 @@ void g_dbus_proxy_unref(GDBusProxy *proxy)
 	if (proxy == NULL)
 		return;
 
-	if (g_atomic_int_dec_and_test(&proxy->ref_count) == FALSE)
+	if (__sync_sub_and_fetch(&proxy->ref_count, 1) > 0)
 		return;
 
 	g_hash_table_destroy(proxy->prop_list);
@@ -1265,7 +1265,7 @@ GDBusClient *g_dbus_client_ref(GDBusClient *client)
 	if (client == NULL)
 		return NULL;
 
-	g_atomic_int_inc(&client->ref_count);
+	__sync_fetch_and_add(&client->ref_count, 1);
 
 	return client;
 }
@@ -1277,7 +1277,7 @@ void g_dbus_client_unref(GDBusClient *client)
 	if (client == NULL)
 		return;
 
-	if (g_atomic_int_dec_and_test(&client->ref_count) == FALSE)
+	if (__sync_sub_and_fetch(&client->ref_count, 1) > 0)
 		return;
 
 	if (client->pending_call != NULL) {
-- 
1.8.2.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 3/6] attrib: Use gcc builtin instead of g_atomic
  2013-04-08 20:56 [PATCH v2 1/6] gitignore: Ignore file generated by Automake 1.13 Lucas De Marchi
  2013-04-08 20:56 ` [PATCH v2 2/6] gdbus: Use gcc builtin instead of g_atomic Lucas De Marchi
@ 2013-04-08 20:56 ` Lucas De Marchi
  2013-04-08 20:56 ` [PATCH v2 4/6] gobex: " Lucas De Marchi
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Lucas De Marchi @ 2013-04-08 20:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Lucas De Marchi

g_atomic_* end up using G_STATIC_ASSERT, causing gcc 4.8 to yell due to
-Wunused-local-typedefs.

/usr/include/glib-2.0/glib/gmacros.h:162:53: error: typedef ‘_GStaticAssertCompileTimeAssertion_2’ locally defined but not used [-Werror=unused-local-typedefs]
 #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1]

Most of the uses of atomic operations were wrong. They were fixed as
well. If we are using atomic operations, reading the variable again
later for logging is not an option, we should use the return of the
atomic function used to fetch the variable.
---
 attrib/gatt.c    | 12 ++++++------
 attrib/gattrib.c | 14 ++++++++------
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/attrib/gatt.c b/attrib/gatt.c
index 38d455a..749e820 100644
--- a/attrib/gatt.c
+++ b/attrib/gatt.c
@@ -79,14 +79,14 @@ static void discover_primary_free(struct discover_primary *dp)
 
 static struct included_discovery *isd_ref(struct included_discovery *isd)
 {
-	g_atomic_int_inc(&isd->refs);
+	__sync_fetch_and_add(&isd->refs, 1);
 
 	return isd;
 }
 
 static void isd_unref(struct included_discovery *isd)
 {
-	if (g_atomic_int_dec_and_test(&isd->refs) == FALSE)
+	if (__sync_sub_and_fetch(&isd->refs, 1) > 0)
 		return;
 
 	if (isd->err)
@@ -582,7 +582,7 @@ static void read_long_destroy(gpointer user_data)
 {
 	struct read_long_data *long_read = user_data;
 
-	if (g_atomic_int_dec_and_test(&long_read->ref) == FALSE)
+	if (__sync_sub_and_fetch(&long_read->ref, 1) > 0)
 		return;
 
 	if (long_read->buffer != NULL)
@@ -627,7 +627,7 @@ static void read_blob_helper(guint8 status, const guint8 *rpdu, guint16 rlen,
 				read_blob_helper, long_read, read_long_destroy);
 
 	if (id != 0) {
-		g_atomic_int_inc(&long_read->ref);
+		__sync_fetch_and_add(&long_read->ref, 1);
 		return;
 	}
 
@@ -664,7 +664,7 @@ static void read_char_helper(guint8 status, const guint8 *rpdu,
 	id = g_attrib_send(long_read->attrib, long_read->id, buf, plen,
 				read_blob_helper, long_read, read_long_destroy);
 	if (id != 0) {
-		g_atomic_int_inc(&long_read->ref);
+		__sync_fetch_and_add(&long_read->ref, 1);
 		return;
 	}
 
@@ -700,7 +700,7 @@ guint gatt_read_char(GAttrib *attrib, uint16_t handle, GAttribResultFunc func,
 	if (id == 0)
 		g_free(long_read);
 	else {
-		g_atomic_int_inc(&long_read->ref);
+		__sync_fetch_and_add(&long_read->ref, 1);
 		long_read->id = id;
 	}
 
diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 37581a3..e6d6022 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -147,12 +147,14 @@ static gboolean is_response(guint8 opcode)
 
 GAttrib *g_attrib_ref(GAttrib *attrib)
 {
+	int refs;
+
 	if (!attrib)
 		return NULL;
 
-	g_atomic_int_inc(&attrib->refs);
+	refs = __sync_add_and_fetch(&attrib->refs, 1);
 
-	DBG("%p: ref=%d", attrib, attrib->refs);
+	DBG("%p: ref=%d", attrib, refs);
 
 	return attrib;
 }
@@ -219,16 +221,16 @@ static void attrib_destroy(GAttrib *attrib)
 
 void g_attrib_unref(GAttrib *attrib)
 {
-	gboolean ret;
+	int refs;
 
 	if (!attrib)
 		return;
 
-	ret = g_atomic_int_dec_and_test(&attrib->refs);
+	refs = __sync_sub_and_fetch(&attrib->refs, 1);
 
-	DBG("%p: ref=%d", attrib, attrib->refs);
+	DBG("%p: ref=%d", attrib, refs);
 
-	if (ret == FALSE)
+	if (refs > 0)
 		return;
 
 	attrib_destroy(attrib);
-- 
1.8.2.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 4/6] gobex: Use gcc builtin instead of g_atomic
  2013-04-08 20:56 [PATCH v2 1/6] gitignore: Ignore file generated by Automake 1.13 Lucas De Marchi
  2013-04-08 20:56 ` [PATCH v2 2/6] gdbus: Use gcc builtin instead of g_atomic Lucas De Marchi
  2013-04-08 20:56 ` [PATCH v2 3/6] attrib: " Lucas De Marchi
@ 2013-04-08 20:56 ` Lucas De Marchi
  2013-04-08 20:56 ` [PATCH v2 5/6] obexd: " Lucas De Marchi
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Lucas De Marchi @ 2013-04-08 20:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Lucas De Marchi

g_atomic_* end up using G_STATIC_ASSERT, causing gcc 4.8 to yell due to
-Wunused-local-typedefs.

/usr/include/glib-2.0/glib/gmacros.h:162:53: error: typedef ‘_GStaticAssertCompileTimeAssertion_2’ locally defined but not used [-Werror=unused-local-typedefs]
 #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1]

Most of the uses of atomic operations were wrong. They were fixed as
well. If we are using atomic operations, reading the variable again
later for logging is not an option, we should use the return of the
atomic function used to fetch the variable.
---
 gobex/gobex.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/gobex/gobex.c b/gobex/gobex.c
index a9bcee9..ce4f284 100644
--- a/gobex/gobex.c
+++ b/gobex/gobex.c
@@ -1315,25 +1315,27 @@ GObex *g_obex_new(GIOChannel *io, GObexTransportType transport_type,
 
 GObex *g_obex_ref(GObex *obex)
 {
+	int refs;
+
 	if (obex == NULL)
 		return NULL;
 
-	g_atomic_int_inc(&obex->ref_count);
+	refs = __sync_add_and_fetch(&obex->ref_count, 1);
 
-	g_obex_debug(G_OBEX_DEBUG_COMMAND, "ref %u", obex->ref_count);
+	g_obex_debug(G_OBEX_DEBUG_COMMAND, "ref %u", refs);
 
 	return obex;
 }
 
 void g_obex_unref(GObex *obex)
 {
-	gboolean last_ref;
+	int refs;
 
-	last_ref = g_atomic_int_dec_and_test(&obex->ref_count);
+	refs = __sync_sub_and_fetch(&obex->ref_count, 1);
 
-	g_obex_debug(G_OBEX_DEBUG_COMMAND, "ref %u", obex->ref_count);
+	g_obex_debug(G_OBEX_DEBUG_COMMAND, "ref %u", refs);
 
-	if (!last_ref)
+	if (refs > 0)
 		return;
 
 	g_slist_free_full(obex->req_handlers, g_free);
-- 
1.8.2.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 5/6] obexd: Use gcc builtin instead of g_atomic
  2013-04-08 20:56 [PATCH v2 1/6] gitignore: Ignore file generated by Automake 1.13 Lucas De Marchi
                   ` (2 preceding siblings ...)
  2013-04-08 20:56 ` [PATCH v2 4/6] gobex: " Lucas De Marchi
@ 2013-04-08 20:56 ` Lucas De Marchi
  2013-04-08 20:56 ` [PATCH v2 6/6] shared: " Lucas De Marchi
  2013-04-08 22:05 ` [PATCH v2 1/6] gitignore: Ignore file generated by Automake 1.13 Johan Hedberg
  5 siblings, 0 replies; 7+ messages in thread
From: Lucas De Marchi @ 2013-04-08 20:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Lucas De Marchi

g_atomic_* end up using G_STATIC_ASSERT, causing gcc 4.8 to yell due to
-Wunused-local-typedefs.

/usr/include/glib-2.0/glib/gmacros.h:162:53: error: typedef ‘_GStaticAssertCompileTimeAssertion_2’ locally defined but not used [-Werror=unused-local-typedefs]
 #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1]

Most of the uses of atomic operations were wrong. They were fixed as
well. If we are using atomic operations, reading the variable again
later for logging is not an option, we should use the return of the
atomic function used to fetch the variable.
---
 obexd/client/session.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/obexd/client/session.c b/obexd/client/session.c
index f677bcb..2e8b113 100644
--- a/obexd/client/session.c
+++ b/obexd/client/session.c
@@ -115,9 +115,9 @@ static GQuark obex_io_error_quark(void)
 
 struct obc_session *obc_session_ref(struct obc_session *session)
 {
-	g_atomic_int_inc(&session->refcount);
+	int refs = __sync_add_and_fetch(&session->refcount, 1);
 
-	DBG("%p: ref=%d", session, session->refcount);
+	DBG("%p: ref=%d", session, refs);
 
 	return session;
 }
@@ -210,13 +210,13 @@ static void session_free(struct obc_session *session)
 
 void obc_session_unref(struct obc_session *session)
 {
-	gboolean ret;
+	int refs;
 
-	ret = g_atomic_int_dec_and_test(&session->refcount);
+	refs = __sync_sub_and_fetch(&session->refcount, 1);
 
-	DBG("%p: ref=%d", session, session->refcount);
+	DBG("%p: ref=%d", session, refs);
 
-	if (ret == FALSE)
+	if (refs > 0)
 		return;
 
 	session_free(session);
-- 
1.8.2.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 6/6] shared: Use gcc builtin instead of g_atomic
  2013-04-08 20:56 [PATCH v2 1/6] gitignore: Ignore file generated by Automake 1.13 Lucas De Marchi
                   ` (3 preceding siblings ...)
  2013-04-08 20:56 ` [PATCH v2 5/6] obexd: " Lucas De Marchi
@ 2013-04-08 20:56 ` Lucas De Marchi
  2013-04-08 22:05 ` [PATCH v2 1/6] gitignore: Ignore file generated by Automake 1.13 Johan Hedberg
  5 siblings, 0 replies; 7+ messages in thread
From: Lucas De Marchi @ 2013-04-08 20:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Lucas De Marchi

g_atomic_* end up using G_STATIC_ASSERT, causing gcc 4.8 to yell due to
-Wunused-local-typedefs.

/usr/include/glib-2.0/glib/gmacros.h:162:53: error: typedef ‘_GStaticAssertCompileTimeAssertion_2’ locally defined but not used [-Werror=unused-local-typedefs]
 #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1]
---
 src/shared/hciemu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/shared/hciemu.c b/src/shared/hciemu.c
index 97ea84e..60a4f47 100644
--- a/src/shared/hciemu.c
+++ b/src/shared/hciemu.c
@@ -308,7 +308,7 @@ struct hciemu *hciemu_ref(struct hciemu *hciemu)
 	if (!hciemu)
 		return NULL;
 
-	g_atomic_int_inc(&hciemu->ref_count);
+	__sync_fetch_and_add(&hciemu->ref_count, 1);
 
 	return hciemu;
 }
@@ -318,7 +318,7 @@ void hciemu_unref(struct hciemu *hciemu)
 	if (!hciemu)
 		return;
 
-	if (g_atomic_int_dec_and_test(&hciemu->ref_count) == FALSE)
+	if (__sync_sub_and_fetch(&hciemu->ref_count, 1) > 0)
 		return;
 
 	g_list_foreach(hciemu->post_command_hooks, destroy_command_hook, NULL);
-- 
1.8.2.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/6] gitignore: Ignore file generated by Automake 1.13
  2013-04-08 20:56 [PATCH v2 1/6] gitignore: Ignore file generated by Automake 1.13 Lucas De Marchi
                   ` (4 preceding siblings ...)
  2013-04-08 20:56 ` [PATCH v2 6/6] shared: " Lucas De Marchi
@ 2013-04-08 22:05 ` Johan Hedberg
  5 siblings, 0 replies; 7+ messages in thread
From: Johan Hedberg @ 2013-04-08 22:05 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: linux-bluetooth, Lucas De Marchi

Hi Lucas,

On Mon, Apr 08, 2013, Lucas De Marchi wrote:
> Automake >= 1.13 enables parallel-tests option which uses a test-driver
> script (copied by automake). Ignore this file.
> ---
>  .gitignore | 4 ++++
>  1 file changed, 4 insertions(+)

All patches in this set have been applied. Thanks.

Johan

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-04-08 22:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-08 20:56 [PATCH v2 1/6] gitignore: Ignore file generated by Automake 1.13 Lucas De Marchi
2013-04-08 20:56 ` [PATCH v2 2/6] gdbus: Use gcc builtin instead of g_atomic Lucas De Marchi
2013-04-08 20:56 ` [PATCH v2 3/6] attrib: " Lucas De Marchi
2013-04-08 20:56 ` [PATCH v2 4/6] gobex: " Lucas De Marchi
2013-04-08 20:56 ` [PATCH v2 5/6] obexd: " Lucas De Marchi
2013-04-08 20:56 ` [PATCH v2 6/6] shared: " Lucas De Marchi
2013-04-08 22:05 ` [PATCH v2 1/6] gitignore: Ignore file generated by Automake 1.13 Johan Hedberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).