diff options
author | Johan Hedberg <johan.hedberg@nokia.com> | 2008-11-06 16:05:59 +0200 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@nokia.com> | 2008-11-06 16:05:59 +0200 |
commit | b877233d59bd60707deb80291add6eb9cac58e37 (patch) | |
tree | 8a246b487a277cc2b69b30714fbf8d44dd9fa4ec /serial/port.c | |
parent | ba62d90d6675de701e2ef066519e2ca0edddf156 (diff) |
Fix checks for port->id value
Diffstat (limited to 'serial/port.c')
-rw-r--r-- | serial/port.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/serial/port.c b/serial/port.c index a446616f..c36e84d1 100644 --- a/serial/port.c +++ b/serial/port.c @@ -162,14 +162,14 @@ static int port_release(struct serial_port *port) g_free(port->dev); port->dev = NULL; - port->id = 0; + port->id = -1; close(rfcomm_ctl); return -err; } static void serial_port_free(struct serial_port *port) { - if (port->id) + if (port->id >= 0) port_release(port); g_free(port->uuid); g_free(port); @@ -187,7 +187,7 @@ static void port_owner_exited(DBusConnection *conn, void *user_data) { struct serial_port *port = user_data; - if (port->id) + if (port->id >= 0) port_release(port); port->listener_id = 0; @@ -399,7 +399,7 @@ static DBusMessage *port_disconnect(DBusConnection *conn, if (!port->listener_id) return failed(msg, "Not connected"); - if (port->id) + if (port->id >= 0) port_release(port); g_dbus_remove_watch(conn, port->listener_id); @@ -463,6 +463,7 @@ int port_register(DBusConnection *conn, const char *path, bdaddr_t *src, port->uuid = g_strdup(uuid); port->channel = channel; port->device = device; + port->id = -1; device->ports = g_slist_append(device->ports, port); |