Skip to contentSkip to conversation

hcid: memory alignment problems on arm

Bluez-devel pHilipp Zabel 2 participants 6 messages Sep 21, 2005 – Sep 22, 2005 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

Hi!

hcid causes alignment traps on arm architecture with the dbus part enabled. I worked around this with the attached patch.
Can anybody help me to do this the right way?

--
Philipp

hcid/dbus.c renamed from hcid/dbus.c.orig +6 -2
@@ -120,6 +121,7 @@
 	DBusMessage *message;
 #ifdef HAVE_DBUS_MESSAGE_ITER_GET_BASIC
 	uint8_t *addr = (uint8_t *) &ci->bdaddr;
+	uint32_t ci_out = ci->out;
 #else
 	DBusMessageIter iter;
 #endif
@@ -138,7 +140,7 @@
 	bacpy(&req->bda, &ci->bdaddr);
 
 #ifdef HAVE_DBUS_MESSAGE_ITER_GET_BASIC
-	dbus_message_append_args(message, DBUS_TYPE_BOOLEAN, &ci->out,
+	dbus_message_append_args(message, DBUS_TYPE_BOOLEAN, &ci_out,
 			DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
 			&addr, sizeof(bdaddr_t), DBUS_TYPE_INVALID);
 #else
@@ -261,6 +263,8 @@
 	DBusMessage *message;
 #ifndef HAVE_DBUS_MESSAGE_ITER_GET_BASIC
 	DBusMessageIter iter;
+#else
+	int32_t tmp_rssi = rssi;
 #endif
 	char *local_addr, *peer_addr;
 	bdaddr_t tmp;
@@ -276,11 +280,12 @@
 	}
 
 #ifdef HAVE_DBUS_MESSAGE_ITER_GET_BASIC
+
 	dbus_message_append_args(message,
 					DBUS_TYPE_STRING, &local_addr,
 					DBUS_TYPE_STRING, &peer_addr,
 					DBUS_TYPE_UINT32, &class,
-					DBUS_TYPE_INT32, &rssi,
+					DBUS_TYPE_INT32, &tmp_rssi,
 					DBUS_TYPE_INVALID);
 #else
 	dbus_message_append_iter_init(message, &iter);
maintainer
#1 lore raw

Hi Philipp,

Quoted 3 lines

hcid causes alignment traps on arm architecture with the dbus part enabled. I worked around this with the attached patch.
Can anybody help me to do this the right way?

the patch looks good, but you must redo it against the latest CVS. I removed the compat code for the D-Bus 0.23 API.

Regards

Marcel

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#2 lore raw

Hi Marcel,

Quoted 2 lines · Marcel Holtmann

the patch looks good, but you must redo it against the latest CVS. I removed the compat code for the D-Bus 0.23 API.

Thanks, I have attached an updated patch against CVS.

--
Philipp

hcid/dbus.c renamed from hcid/dbus.c.orig +4 -2
@@ -124,6 +124,7 @@
 	DBusPendingCall *pending = NULL;
 	struct pin_request *req;
 	uint8_t *addr = (uint8_t *) &ci->bdaddr;
+	uint32_t tmp_out = ci->out;
 
 	message = dbus_message_new_method_call(SERVICE_NAME, PATH_NAME,
 						INTERFACE_NAME, REQUEST_NAME);
@@ -136,7 +137,7 @@
 	req->dev = dev;
 	bacpy(&req->bda, &ci->bdaddr);
 
-	dbus_message_append_args(message, DBUS_TYPE_BOOLEAN, &ci->out,
+	dbus_message_append_args(message, DBUS_TYPE_BOOLEAN, &tmp_out,
 			DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
 			&addr, sizeof(bdaddr_t), DBUS_TYPE_INVALID);
 
@@ -233,6 +234,7 @@
 {
 	DBusMessage *message;
 	char *local_addr, *peer_addr;
+	int32_t tmp_rssi = rssi;
 	bdaddr_t tmp;
 
 	baswap(&tmp, local); local_addr = batostr(&tmp);
@@ -249,7 +251,7 @@
 					DBUS_TYPE_STRING, &local_addr,
 					DBUS_TYPE_STRING, &peer_addr,
 					DBUS_TYPE_UINT32, &class,
-					DBUS_TYPE_INT32, &rssi,
+					DBUS_TYPE_INT32, &tmp_rssi,
 					DBUS_TYPE_INVALID);
 
 	if (dbus_connection_send(connection, message, NULL) == FALSE) {
maintainer
#3 lore raw

Hi Philipp,

Quoted 5 lines · Marcel Holtmann
Quoted 2 lines

the patch looks good, but you must redo it against the latest CVS. I removed the compat code for the D-Bus 0.23 API.

Thanks, I have attached an updated patch against CVS.

is the attached patch also working for you? I think it is better to use the D-Bus specific types.

Regards

Marcel

Index: hcid/dbus.c
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus.c,v
retrieving revision 1.16

dbus.c +6 -3
diff -u -r1.16 dbus.c
@@ -124,6 +124,7 @@
 	DBusPendingCall *pending = NULL;
 	struct pin_request *req;
 	uint8_t *addr = (uint8_t *) &ci->bdaddr;
+	dbus_uint32_t out = ci->out;
 
 	message = dbus_message_new_method_call(SERVICE_NAME, PATH_NAME,
 						INTERFACE_NAME, REQUEST_NAME);
@@ -136,7 +137,7 @@
 	req->dev = dev;
 	bacpy(&req->bda, &ci->bdaddr);
 
-	dbus_message_append_args(message, DBUS_TYPE_BOOLEAN, &ci->out,
+	dbus_message_append_args(message, DBUS_TYPE_BOOLEAN, &out,
 			DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
 			&addr, sizeof(bdaddr_t), DBUS_TYPE_INVALID);
 
@@ -233,6 +234,8 @@
 {
 	DBusMessage *message;
 	char *local_addr, *peer_addr;
+	dbus_uint32_t tmp_class;
+	dbus_int32_t tmp_rssi = rssi;
 	bdaddr_t tmp;
 
 	baswap(&tmp, local); local_addr = batostr(&tmp);
@@ -248,8 +251,8 @@
 	dbus_message_append_args(message,
 					DBUS_TYPE_STRING, &local_addr,
 					DBUS_TYPE_STRING, &peer_addr,
-					DBUS_TYPE_UINT32, &class,
-					DBUS_TYPE_INT32, &rssi,
+					DBUS_TYPE_UINT32, &tmp_class,
+					DBUS_TYPE_INT32, &tmp_rssi,
 					DBUS_TYPE_INVALID);
 
 	if (dbus_connection_send(connection, message, NULL) == FALSE) {
maintainer
#4 lore raw

Hi Philipp,

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

the patch looks good, but you must redo it against the latest CVS. I removed the compat code for the D-Bus 0.23 API.

Thanks, I have attached an updated patch against CVS.

is the attached patch also working for you? I think it is better to use the D-Bus specific types.

oops. Wrong patch. Try this one.

Regards

Marcel

Index: hcid/dbus.c
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus.c,v
retrieving revision 1.16

dbus.c +6 -3
diff -u -r1.16 dbus.c
@@ -124,6 +124,7 @@
 	DBusPendingCall *pending = NULL;
 	struct pin_request *req;
 	uint8_t *addr = (uint8_t *) &ci->bdaddr;
+	dbus_bool_t out = ci->out;
 
 	message = dbus_message_new_method_call(SERVICE_NAME, PATH_NAME,
 						INTERFACE_NAME, REQUEST_NAME);
@@ -136,7 +137,7 @@
 	req->dev = dev;
 	bacpy(&req->bda, &ci->bdaddr);
 
-	dbus_message_append_args(message, DBUS_TYPE_BOOLEAN, &ci->out,
+	dbus_message_append_args(message, DBUS_TYPE_BOOLEAN, &out,
 			DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
 			&addr, sizeof(bdaddr_t), DBUS_TYPE_INVALID);
 
@@ -233,6 +234,8 @@
 {
 	DBusMessage *message;
 	char *local_addr, *peer_addr;
+	dbus_uint32_t tmp_class = class;
+	dbus_int32_t tmp_rssi = rssi;
 	bdaddr_t tmp;
 
 	baswap(&tmp, local); local_addr = batostr(&tmp);
@@ -248,8 +251,8 @@
 	dbus_message_append_args(message,
 					DBUS_TYPE_STRING, &local_addr,
 					DBUS_TYPE_STRING, &peer_addr,
-					DBUS_TYPE_UINT32, &class,
-					DBUS_TYPE_INT32, &rssi,
+					DBUS_TYPE_UINT32, &tmp_class,
+					DBUS_TYPE_INT32, &tmp_rssi,
 					DBUS_TYPE_INVALID);
 
 	if (dbus_connection_send(connection, message, NULL) == FALSE) {
#5 lore raw

Hi Marcel,

Quoted 2 lines
Quoted 2 lines

is the attached patch also working for you? I think it is better to use the D-Bus specific types.

It does work exactly the same as mine.
I still don't see pin request messages on the system message bus, but the alignment issues are gone.

thanks
--
Philipp

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel