>From 1bf944af8a321cebe2ddc45d0649f744c8828bab Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 26 Apr 2013 16:20:22 -0400 Subject: [PATCH] Add libgsystem as a git submodule 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 | 3 +++ Makefile.am | 7 +++++++ libgsystem | 1 + src/Makefile.am | 2 ++ src/main.c | 50 ++++++++++++-------------------------------------- 5 files changed, 25 insertions(+), 38 deletions(-) create mode 100644 .gitmodules create mode 160000 libgsystem diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..e93bbea --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "libgsystem"] + path = libgsystem + url = git://git.gnome.org/libgsystem diff --git a/Makefile.am b/Makefile.am index 2847616..9419d35 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 diff --git a/libgsystem b/libgsystem new file mode 160000 index 0000000..51736db --- /dev/null +++ b/libgsystem @@ -0,0 +1 @@ +Subproject commit 51736db5f49b4b798fd2f9d0ccb8eff453105162 diff --git a/src/Makefile.am b/src/Makefile.am index 113b527..f81c37a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -26,6 +26,7 @@ endif SUBDIRS += . tests INCLUDES = -I${top_srcdir} \ + -I${top_srcdir}/libgsystem \ -I${top_builddir}/include \ -I${top_srcdir}/include \ -I${top_builddir}/src/generated \ @@ -324,6 +325,7 @@ NetworkManager_CPPFLAGS += -DCKDB_PATH=\"${CKDB_PATH}\" endif NetworkManager_LDADD = \ + $(top_builddir)/libgsystem.la \ ./generated/libnm-generated.la \ ./logging/libnm-logging.la \ ./config/libnm-config.la \ diff --git a/src/main.c b/src/main.c index ed71bb6..37e05c4 100644 --- a/src/main.c +++ b/src/main.c @@ -38,6 +38,7 @@ #include #include +#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); } -- 1.7.1