core: add libgsystem as a git submodule
authorColin Walters <walters@verbum.org>
Fri, 26 Apr 2013 20:42:54 +0000 (16:42 -0400)
committerDan Williams <dcbw@redhat.com>
Thu, 16 May 2013 19:08:09 +0000 (14:08 -0500)
And change src/main.c to use the local allocation macros.  This
results in much cleaner code, as one can see from the diff.

Because libgsystem is designed for nonrecursive make, it fits best in
the current recursive setup if we build . first.  This will be a lot
nicer when we switch NM to a nonrecursive setup.

.gitmodules [new file with mode: 0644]
Makefile.am
autogen.sh
libgsystem [new submodule]
src/Makefile.am
src/main.c

diff --git a/.gitmodules b/.gitmodules
new file mode 100644 (file)
index 0000000..e93bbea
--- /dev/null
@@ -0,0 +1,3 @@
+[submodule "libgsystem"]
+       path = libgsystem
+       url = git://git.gnome.org/libgsystem
index 32fc74d..9976a2a 100644 (file)
@@ -1,6 +1,7 @@
 include $(GLIB_MAKEFILE)
 
 SUBDIRS = \
+       . \
        include \
        libnm-util \
        libnm-glib \
@@ -53,3 +54,9 @@ CLEANFILES = cscope.in.out cscope.out cscope.po.out
 .PHONY: cscope
 cscope:
        cscope -b -q -R -Iinclude -ssrc -slibnm-glib -slibnm-util -scli/src;
+
+libgsystem_srcpath := libgsystem
+libgsystem_cflags := $(GLIB_CFLAGS) -I$(srcdir)/libgsystem
+libgsystem_libs = $(GLIB_LIBS)
+include libgsystem/Makefile-libgsystem.am
+noinst_LTLIBRARIES = libgsystem.la
index ef6d20f..8c6179a 100755 (executable)
@@ -13,6 +13,14 @@ PKG_NAME=NetworkManager
     exit 1
 }
 
+# Fetch submodules if needed
+if test ! -f src/libgsystem/README;
+then
+  echo "+ Setting up submodules"
+  git submodule init
+  git submodule update
+fi
+
 (cd $srcdir;
     gtkdocize || exit 1
     autopoint --force
diff --git a/libgsystem b/libgsystem
new file mode 160000 (submodule)
index 0000000..be1b3b9
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit be1b3b9d3dbfacf15ede143de377452a92976468
index 12a7aa0..d34e911 100644 (file)
@@ -25,6 +25,7 @@ endif
 INCLUDES =                             \
        -I$(top_srcdir)/include         \
        -I$(top_builddir)/include       \
+       -I${top_srcdir}/libgsystem      \
        -I$(top_srcdir)/libnm-util      \
        -I$(top_builddir)/libnm-util    \
        -I$(top_srcdir)/callouts
@@ -42,7 +43,7 @@ sbin_PROGRAMS = NetworkManager
 NetworkManager_SOURCES = \
        main.c
 
-NetworkManager_LDADD = libNetworkManager.la
+NetworkManager_LDADD = libNetworkManager.la $(top_builddir)/libgsystem.la
 
 noinst_LTLIBRARIES = libNetworkManager.la
 
index ed71bb6..37e05c4 100644 (file)
@@ -38,6 +38,7 @@
 #include <gmodule.h>
 #include <string.h>
 
+#include "gsystem-local-alloc.h"
 #include "NetworkManager.h"
 #include "NetworkManagerUtils.h"
 #include "nm-manager.h"
@@ -305,18 +306,19 @@ main (int argc, char *argv[])
        GOptionContext *opt_ctx = NULL;
        gboolean become_daemon = FALSE;
        gboolean g_fatal_warnings = FALSE;
-       char *pidfile = NULL, *state_file = NULL;
+       gs_free char *pidfile = NULL;
+       gs_free char *state_file = NULL;
        gboolean wifi_enabled = TRUE, net_enabled = TRUE, wwan_enabled = TRUE, wimax_enabled = TRUE;
        gboolean success, show_version = FALSE;
        NMPolicy *policy = NULL;
-       NMVPNManager *vpn_manager = NULL;
-       NMDnsManager *dns_mgr = NULL;
-       NMDBusManager *dbus_mgr = NULL;
-       NMSupplicantManager *sup_mgr = NULL;
-       NMDHCPManager *dhcp_mgr = NULL;
-       NMFirewallManager *fw_mgr = NULL;
-       NMSettings *settings = NULL;
-       NMConfig *config;
+       gs_unref_object NMVPNManager *vpn_manager = NULL;
+       gs_unref_object NMDnsManager *dns_mgr = NULL;
+       gs_unref_object NMDBusManager *dbus_mgr = NULL;
+       gs_unref_object NMSupplicantManager *sup_mgr = NULL;
+       gs_unref_object NMDHCPManager *dhcp_mgr = NULL;
+       gs_unref_object NMFirewallManager *fw_mgr = NULL;
+       gs_unref_object NMSettings *settings = NULL;
+       gs_unref_object NMConfig *config = NULL;
        GError *error = NULL;
        gboolean wrote_pidfile = FALSE;
 
@@ -579,41 +581,13 @@ done:
        if (policy)
                nm_policy_destroy (policy);
 
-       if (manager)
-               g_object_unref (manager);
-
-       if (settings)
-               g_object_unref (settings);
-
-       if (vpn_manager)
-               g_object_unref (vpn_manager);
-
-       if (dns_mgr)
-               g_object_unref (dns_mgr);
-
-       if (dhcp_mgr)
-               g_object_unref (dhcp_mgr);
-
-       if (sup_mgr)
-               g_object_unref (sup_mgr);
-
-       if (fw_mgr)
-               g_object_unref (fw_mgr);
-
-       if (dbus_mgr)
-               g_object_unref (dbus_mgr);
+       g_clear_object (&manager);
 
        nm_logging_shutdown ();
 
        if (pidfile && wrote_pidfile)
                unlink (pidfile);
 
-       g_object_unref (config);
-
-       /* Free options */
-       g_free (pidfile);
-       g_free (state_file);
-
        nm_log_info (LOGD_CORE, "exiting (%s)", success ? "success" : "error");
        exit (success ? 0 : 1);
 }