[PATCH] android/hal: Fix using void pointer in math operations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Andrei Emeltchenko <andrei.emeltchenko@xxxxxxxxx>

Fixes following compiler warnings:
...
hal-bluetooth.c: In function 'handle_adapter_props_changed':
hal-bluetooth.c:57:9: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
hal-bluetooth.c:57:29: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
hal-bluetooth.c:57:51: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
hal-bluetooth.c:66:5: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
...
---
 android/hal-bluetooth.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index fc60d72..0c083de 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -44,17 +44,18 @@ static void handle_adapter_props_changed(void *buf, uint16_t len)
 	struct hal_ev_adapter_props_changed *ev = buf;
 	bt_property_t props[ev->num_props];
 	struct hal_property *hal_prop;
-	void *p;
+	uint8_t *p;
 	int i;
 
 	if (!bt_hal_cbacks->adapter_properties_cb)
 		return;
 
 	hal_prop = ev->props;
-	p = ev->props;
+	p = (uint8_t *) ev->props;
 
 	for (i = 0; i < ev->num_props; i++) {
-		if (p + sizeof(*hal_prop) + hal_prop->len > buf + len) {
+		if (p + sizeof(*hal_prop) + hal_prop->len >
+							(uint8_t *) buf + len) {
 			error("invalid adapter properties event, aborting");
 			exit(EXIT_FAILURE);
 		}
@@ -64,7 +65,7 @@ static void handle_adapter_props_changed(void *buf, uint16_t len)
 		props[i].val = hal_prop->val;
 
 		p += sizeof(*hal_prop) + hal_prop->len;
-		hal_prop = p;
+		hal_prop = (struct hal_property *) p;
 
 		DBG("prop[%d]: %s", i, btproperty2str(&props[i]));
 	}
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux