2012-12-01 00:36:56

by Vinicius Costa Gomes

[permalink] [raw]
Subject: [PATCH BlueZ v2 1/2] input: Fix emitting a signal for a non-existant interface

When the 'org.bluez.Input' interface was removed, this should have been
removed as well, now it is causing a segmentation fault.
---
profiles/input/device.c | 6 ------
1 file changed, 6 deletions(-)

diff --git a/profiles/input/device.c b/profiles/input/device.c
index 2871cc3..7538297 100644
--- a/profiles/input/device.c
+++ b/profiles/input/device.c
@@ -160,9 +160,6 @@ static gboolean intr_watch_cb(GIOChannel *chan, GIOCondition cond, gpointer data
if ((cond & (G_IO_HUP | G_IO_ERR)) && idev->ctrl_watch)
g_io_channel_shutdown(chan, TRUE, NULL);

- g_dbus_emit_property_changed(idev->conn, idev->path,
- INPUT_DEVICE_INTERFACE, "Connected");
-
device_remove_disconnect_watch(idev->device, idev->dc_id);
idev->dc_id = 0;

@@ -503,9 +500,6 @@ static int input_device_connected(struct input_device *idev)
if (err < 0)
return err;

- g_dbus_emit_property_changed(idev->conn, idev->path,
- INPUT_DEVICE_INTERFACE, "Connected");
-
idev->dc_id = device_add_disconnect_watch(idev->device, disconnect_cb,
idev, NULL);

--
1.8.0



2012-12-01 00:36:57

by Vinicius Costa Gomes

[permalink] [raw]
Subject: [PATCH BlueZ v2 2/2] input: Remove leftovers from the Input iface removal

Now that the Input interface is removed, the only way to connect is
via the Profile interface, so no need to separate the way that
connection is made.
---
profiles/input/device.c | 37 ++++++-------------------------------
1 file changed, 6 insertions(+), 31 deletions(-)

diff --git a/profiles/input/device.c b/profiles/input/device.c
index 7538297..8464062 100644
--- a/profiles/input/device.c
+++ b/profiles/input/device.c
@@ -64,14 +64,8 @@
#define FI_FLAG_CONNECTED 1

struct pending_connect {
- bool local;
- union {
- struct {
- struct btd_profile *profile;
- btd_profile_cb cb;
- } p;
- DBusMessage *msg;
- };
+ struct btd_profile *profile;
+ btd_profile_cb cb;
};

struct input_device {
@@ -119,11 +113,8 @@ static void input_device_free(struct input_device *idev)
g_free(idev->name);
g_free(idev->path);

- if (idev->pending) {
- if (idev->pending->local)
- dbus_message_unref(idev->pending->msg);
+ if (idev->pending)
g_free(idev->pending);
- }

if (idev->ctrl_watch > 0)
g_source_remove(idev->ctrl_watch);
@@ -510,8 +501,6 @@ static void connect_reply(struct input_device *idev, int err,
const char *err_msg)
{
struct pending_connect *pending = idev->pending;
- DBusConnection *conn = btd_get_dbus_connection();
- DBusMessage *reply;

if (!pending)
return;
@@ -521,20 +510,7 @@ static void connect_reply(struct input_device *idev, int err,
if (err_msg)
error("%s", err_msg);

- if (!pending->local) {
- pending->p.cb(pending->p.profile, idev->device, err);
- g_free(pending);
- return;
- }
-
- if (err_msg) {
- reply = btd_error_failed(idev->pending->msg, err_msg);
- g_dbus_send_message(conn, reply);
- } else {
- g_dbus_send_reply(conn, pending->msg, DBUS_TYPE_INVALID);
- }
-
- dbus_message_unref(pending->msg);
+ pending->cb(pending->profile, idev->device, err);
g_free(pending);
}

@@ -667,9 +643,8 @@ int input_device_connect(struct btd_device *dev, struct btd_profile *profile,
return -EALREADY;

idev->pending = g_new0(struct pending_connect, 1);
- idev->pending->local = false;
- idev->pending->p.profile = profile;
- idev->pending->p.cb = cb;
+ idev->pending->profile = profile;
+ idev->pending->cb = cb;

return dev_connect(idev);
}
--
1.8.0


2012-12-01 09:13:45

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH BlueZ v2 1/2] input: Fix emitting a signal for a non-existant interface

Hi Vinicius,

On Fri, Nov 30, 2012, Vinicius Costa Gomes wrote:
> When the 'org.bluez.Input' interface was removed, this should have been
> removed as well, now it is causing a segmentation fault.
> ---
> profiles/input/device.c | 6 ------
> 1 file changed, 6 deletions(-)

Both patches have been applied. Thanks.

Johan