From 1556df2283e8480f3b96e9159940e606c4e2fe43 Mon Sep 17 00:00:00 2001 From: Claudio Takahasi Date: Fri, 13 Apr 2007 13:11:51 +0000 Subject: network: code cleanup --- network/connection.c | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) (limited to 'network/connection.c') diff --git a/network/connection.c b/network/connection.c index 0e9311c4..e4f759aa 100644 --- a/network/connection.c +++ b/network/connection.c @@ -31,6 +31,8 @@ #include #include +#include + #include #include #include @@ -39,15 +41,13 @@ #include -#include - #include "logging.h" #include "dbus.h" #include "error.h" #include "common.h" +#include "connection.h" #define NETWORK_CONNECTION_INTERFACE "org.bluez.network.Connection" -#include "connection.h" typedef enum { CONNECTED, @@ -56,17 +56,17 @@ typedef enum { } conn_state; struct network_conn { - DBusConnection *conn; - DBusMessage *msg; - bdaddr_t src; - bdaddr_t dst; - char *path; /* D-Bus path */ - char dev[16]; /* BNEP interface name */ - char *name; - char *desc; - uint16_t id; /* Service Class Identifier */ - conn_state state; - int sk; + DBusConnection *conn; + DBusMessage *msg; + bdaddr_t src; + bdaddr_t dst; + char *path; /* D-Bus path */ + char dev[16]; /* BNEP interface name */ + char *name; + char *desc; + uint16_t id; /* Service Class Identifier */ + conn_state state; + int sk; }; struct __service_16 { @@ -579,7 +579,9 @@ int connection_register(DBusConnection *conn, const char *path, if (!dbus_connection_register_object_path(conn, path, &connection_table, nc)) { error("D-Bus failed to register %s path", path); - goto fail; + + connection_free(nc); + return -1; } nc->path = g_strdup(path); @@ -610,14 +612,10 @@ int connection_register(DBusConnection *conn, const char *path, nc->conn = conn; info("Registered connection path:%s", path); return 0; -fail: - connection_free(nc); - return -1; } -int -connection_find_data(DBusConnection *conn, const char *path, - const char *pattern) +int connection_find_data(DBusConnection *conn, + const char *path, const char *pattern) { struct network_conn *nc; char addr[18]; @@ -625,15 +623,15 @@ connection_find_data(DBusConnection *conn, const char *path, if (!dbus_connection_get_object_path_data(conn, path, (void *) &nc)) return -1; - if (strcmp(pattern, nc->dev) == 0) + if (strcasecmp(pattern, nc->dev) == 0) return 0; - if (strcmp(pattern, nc->name) == 0) + if (strcasecmp(pattern, nc->name) == 0) return 0; ba2str(&nc->dst, addr); - if (strcmp(pattern, addr) == 0) + if (strcasecmp(pattern, addr) == 0) return 0; return -1; -- cgit