[pulseaudio-discuss] [PATCH v0 04/11] bluetooth: Remove const qualifier for device

Mikel Astiz mikel.astiz.oss at gmail.com
Mon Oct 22 01:46:36 PDT 2012


From: Mikel Astiz <mikel.astiz at bmw-carit.de>

The internal API in bluetooth-util should not use the const qualifier
for operations involving a device object. After all, the structure
contains many pointers and thus the const qualifier provides no real
protection.
---
 src/modules/bluetooth/bluetooth-util.c          |  6 +++---
 src/modules/bluetooth/bluetooth-util.h          |  6 +++---
 src/modules/bluetooth/module-bluetooth-device.c | 10 +++++-----
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index f4f60c4..b9ee8cc 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -919,7 +919,7 @@ fail:
     return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 }
 
-const pa_bluetooth_device* pa_bluetooth_discovery_get_by_address(pa_bluetooth_discovery *y, const char* address) {
+pa_bluetooth_device* pa_bluetooth_discovery_get_by_address(pa_bluetooth_discovery *y, const char* address) {
     pa_bluetooth_device *d;
     void *state = NULL;
 
@@ -937,7 +937,7 @@ const pa_bluetooth_device* pa_bluetooth_discovery_get_by_address(pa_bluetooth_di
     return NULL;
 }
 
-const pa_bluetooth_device* pa_bluetooth_discovery_get_by_path(pa_bluetooth_discovery *y, const char* path) {
+pa_bluetooth_device* pa_bluetooth_discovery_get_by_path(pa_bluetooth_discovery *y, const char* path) {
     pa_bluetooth_device *d;
 
     pa_assert(y);
@@ -970,7 +970,7 @@ pa_bluetooth_transport* pa_bluetooth_discovery_get_transport(pa_bluetooth_discov
     return NULL;
 }
 
-pa_bluetooth_transport* pa_bluetooth_device_get_transport(const pa_bluetooth_device *d, enum profile profile) {
+pa_bluetooth_transport* pa_bluetooth_device_get_transport(pa_bluetooth_device *d, enum profile profile) {
     pa_bluetooth_transport *t;
     void *state = NULL;
 
diff --git a/src/modules/bluetooth/bluetooth-util.h b/src/modules/bluetooth/bluetooth-util.h
index e529891..386c22e 100644
--- a/src/modules/bluetooth/bluetooth-util.h
+++ b/src/modules/bluetooth/bluetooth-util.h
@@ -130,11 +130,11 @@ void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *d);
 
 void pa_bluetooth_discovery_sync(pa_bluetooth_discovery *d);
 
-const pa_bluetooth_device* pa_bluetooth_discovery_get_by_path(pa_bluetooth_discovery *d, const char* path);
-const pa_bluetooth_device* pa_bluetooth_discovery_get_by_address(pa_bluetooth_discovery *d, const char* address);
+pa_bluetooth_device* pa_bluetooth_discovery_get_by_path(pa_bluetooth_discovery *d, const char* path);
+pa_bluetooth_device* pa_bluetooth_discovery_get_by_address(pa_bluetooth_discovery *d, const char* address);
 
 pa_bluetooth_transport* pa_bluetooth_discovery_get_transport(pa_bluetooth_discovery *y, const char *path);
-pa_bluetooth_transport* pa_bluetooth_device_get_transport(const pa_bluetooth_device *d, enum profile profile);
+pa_bluetooth_transport* pa_bluetooth_device_get_transport(pa_bluetooth_device *d, enum profile profile);
 
 int pa_bluetooth_transport_acquire(pa_bluetooth_transport *t, const char *accesstype, size_t *imtu, size_t *omtu);
 void pa_bluetooth_transport_release(pa_bluetooth_transport *t, const char *accesstype);
diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index 4bf5f03..30a1807 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -379,7 +379,7 @@ static pa_bt_audio_state_t get_profile_audio_state(const struct userdata *u, con
 
 static int bt_transport_acquire(struct userdata *u, pa_bool_t start) {
     const char *accesstype = "rw";
-    const pa_bluetooth_device *d;
+    pa_bluetooth_device *d;
 
     pa_assert(u->transport);
 
@@ -1974,7 +1974,7 @@ static pa_hook_result_t transport_removed_cb(pa_bluetooth_transport *t, void *ca
 
 /* Run from main thread */
 static int setup_transport(struct userdata *u) {
-    const pa_bluetooth_device *d;
+    pa_bluetooth_device *d;
     pa_bluetooth_transport *t;
 
     pa_assert(u);
@@ -2471,8 +2471,8 @@ static int add_card(struct userdata *u, const pa_bluetooth_device *device) {
 }
 
 /* Run from main thread */
-static const pa_bluetooth_device* find_device(struct userdata *u, const char *address, const char *path) {
-    const pa_bluetooth_device *d = NULL;
+static pa_bluetooth_device* find_device(struct userdata *u, const char *address, const char *path) {
+    pa_bluetooth_device *d = NULL;
 
     pa_assert(u);
 
@@ -2531,7 +2531,7 @@ int pa__init(pa_module* m) {
     const char *address, *path;
     DBusError err;
     char *mike, *speaker;
-    const pa_bluetooth_device *device;
+    pa_bluetooth_device *device;
 
     pa_assert(m);
 
-- 
1.7.11.7



More information about the pulseaudio-discuss mailing list