]> git.meshlink.io Git - catta/commitdiff
* Some minor error handling cleanups
authorLennart Poettering <lennart@poettering.net>
Thu, 11 Aug 2005 20:38:33 +0000 (20:38 +0000)
committerLennart Poettering <lennart@poettering.net>
Thu, 11 Aug 2005 20:38:33 +0000 (20:38 +0000)
* Please use uint16_t for port numbers. This type is defined in inttypes.h which is available nearly everywhere

git-svn-id: file:///home/lennart/svn/public/avahi/trunk@297 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe

avahi-client/client.c
avahi-client/client.h
avahi-client/entrygroup.c

index 2ef1bf6cebb5dc5e1c28bc01dc806729ce341695..49c82d53d086cc8061eee0069f2be1868f891473 100644 (file)
@@ -197,27 +197,23 @@ avahi_client_new (AvahiClientCallback callback, void *user_data)
     AvahiClient *tmp = NULL;
     DBusError error;
 
-    tmp = g_new (AvahiClient, 1);
+    dbus_error_init (&error);
 
-    if (tmp == NULL)
+    if (!(tmp = malloc(sizeof(AvahiClient))))
         goto fail;
 
     AVAHI_LLIST_HEAD_INIT(AvahiEntryGroup, tmp->groups);
     AVAHI_LLIST_HEAD_INIT(AvahiDomainBrowser, tmp->domain_browsers);
     AVAHI_LLIST_HEAD_INIT(AvahiServieTypeBrowser, tmp->service_type_browsers);
-
-    dbus_error_init (&error);
-
+    
     tmp->bus = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
 
-    dbus_connection_setup_with_g_main (tmp->bus, NULL);
-
     if (dbus_error_is_set (&error)) {
         fprintf(stderr, "Error getting system d-bus: %s\n", error.message);
-        dbus_error_free (&error);
         goto fail;
     }
 
+    dbus_connection_setup_with_g_main (tmp->bus, NULL);
     dbus_connection_set_exit_on_disconnect (tmp->bus, FALSE);
 
     if (!dbus_connection_add_filter (tmp->bus, filter_func, tmp, NULL))
@@ -236,7 +232,6 @@ avahi_client_new (AvahiClientCallback callback, void *user_data)
     if (dbus_error_is_set (&error))
     {
         fprintf (stderr, "Error adding filter match: %s\n", error.message);
-        dbus_error_free (&error);
         goto fail;
 
     }   
@@ -251,7 +246,6 @@ avahi_client_new (AvahiClientCallback callback, void *user_data)
     if (dbus_error_is_set (&error))
     {
         fprintf (stderr, "Error adding filter match: %s\n", error.message);
-        dbus_error_free (&error);
         goto fail;
     }
 
@@ -265,6 +259,10 @@ avahi_client_new (AvahiClientCallback callback, void *user_data)
 
 fail:
     free (tmp);
+
+    if (dbus_error_is_set(&error))
+        dbus_error_free(&error);
+        
     return NULL;
 }
 
index 9654206963c69f7c2a6cdaf179cfdae956098120..f3716ebc049de21bc095dbe8a8df243ecf1d3f66 100644 (file)
@@ -22,6 +22,8 @@
   USA.
 ***/
 
+#include <inttypes.h>
+
 #include <avahi-common/cdecl.h>
 #include <avahi-common/address.h>
 #include <avahi-common/strlst.h>
@@ -104,7 +106,7 @@ avahi_entry_group_add_service (AvahiEntryGroup *group,
                                const char *type,
                                const char *domain,
                                const char *host,
-                               int port,
+                               uint16_t port,
                                AvahiStringList *txt);
 
 /** Get the D-Bus path of an AvahiEntryGroup object, for debugging purposes only. */
index 06f8d9d0bfe0427842fbb359f8be4e23c9a1baa3..ea56ee2591fc362ebeb76657ab20d59dcfc138ef 100644 (file)
@@ -204,7 +204,7 @@ avahi_entry_group_add_service (AvahiEntryGroup *group,
                                const char *type,
                                const char *domain,
                                const char *host,
-                               int port,
+                               uint16_t port,
                                AvahiStringList *txt)
 {
     DBusMessage *message;