mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-09-06 17:14:02 +00:00
merge branch 'th/libgsystem'
Remove libgsystem submodule and include the gsystem-local-alloc.h header file directly. Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
commit
fad552694e
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -30,6 +30,8 @@ cscope.*out
|
|||
valgrind-*.log
|
||||
*-glue.h
|
||||
|
||||
/libgsystem/
|
||||
|
||||
/ABOUT-NLS
|
||||
/COPYING
|
||||
/INSTALL
|
||||
|
|
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -1,3 +0,0 @@
|
|||
[submodule "libgsystem"]
|
||||
path = libgsystem
|
||||
url = git://git.gnome.org/libgsystem
|
|
@ -66,10 +66,4 @@ CLEANFILES = cscope.in.out cscope.out cscope.po.out
|
|||
cscope:
|
||||
cscope -b -q -R -Iinclude -ssrc -slibnm-glib -slibnm-util -scli/src;
|
||||
|
||||
libgsystem_srcpath := libgsystem
|
||||
libgsystem_cflags := $(filter-out -DGLIB_VERSION%,$(GLIB_CFLAGS)) -I$(srcdir)/libgsystem
|
||||
libgsystem_libs = $(GLIB_LIBS)
|
||||
include libgsystem/Makefile-libgsystem.am
|
||||
noinst_LTLIBRARIES = libgsystem.la
|
||||
|
||||
.PHONY: cscope
|
||||
|
|
|
@ -22,13 +22,6 @@ PKG_NAME=NetworkManager
|
|||
|
||||
cd $srcdir
|
||||
|
||||
# Fetch submodules if needed
|
||||
if test -d $srcdir/.git; then
|
||||
echo "+ Setting up submodules"
|
||||
git submodule init
|
||||
git submodule update
|
||||
fi
|
||||
|
||||
gtkdocize
|
||||
autopoint --force
|
||||
AUTOPOINT='intltoolize --automake --copy' autoreconf --force --install --verbose
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
EXTRA_DIST = \
|
||||
gsystem-local-alloc.h \
|
||||
nm-dbus-glib-types.h \
|
||||
nm-glib-compat.h \
|
||||
nm-gvaluearray-compat.h \
|
||||
|
|
183
include/gsystem-local-alloc.h
Normal file
183
include/gsystem-local-alloc.h
Normal file
|
@ -0,0 +1,183 @@
|
|||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
||||
*
|
||||
* Copyright (C) 2012 Colin Walters <walters@verbum.org>.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GSYSTEM_LOCAL_ALLOC_H__
|
||||
#define __GSYSTEM_LOCAL_ALLOC_H__
|
||||
|
||||
#include <gio/gio.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GS_DEFINE_CLEANUP_FUNCTION(Type, name, func) \
|
||||
static inline void name (void *v) \
|
||||
{ \
|
||||
func (*(Type*)v); \
|
||||
}
|
||||
|
||||
#define GS_DEFINE_CLEANUP_FUNCTION0(Type, name, func) \
|
||||
static inline void name (void *v) \
|
||||
{ \
|
||||
if (*(Type*)v) \
|
||||
func (*(Type*)v); \
|
||||
}
|
||||
|
||||
/* These functions shouldn't be invoked directly;
|
||||
* they are stubs that:
|
||||
* 1) Take a pointer to the location (typically itself a pointer).
|
||||
* 2) Provide %NULL-safety where it doesn't exist already (e.g. g_object_unref)
|
||||
*/
|
||||
GS_DEFINE_CLEANUP_FUNCTION0(GArray*, gs_local_array_unref, g_array_unref)
|
||||
GS_DEFINE_CLEANUP_FUNCTION0(GBytes*, gs_local_bytes_unref, g_bytes_unref)
|
||||
GS_DEFINE_CLEANUP_FUNCTION0(GChecksum*, gs_local_checksum_free, g_checksum_free)
|
||||
GS_DEFINE_CLEANUP_FUNCTION0(GKeyFile*, gs_local_keyfile_unref, g_key_file_unref)
|
||||
GS_DEFINE_CLEANUP_FUNCTION0(GError*, gs_local_free_error, g_error_free)
|
||||
GS_DEFINE_CLEANUP_FUNCTION0(GHashTable*, gs_local_hashtable_unref, g_hash_table_unref)
|
||||
GS_DEFINE_CLEANUP_FUNCTION(GList*, gs_local_free_list, g_list_free)
|
||||
GS_DEFINE_CLEANUP_FUNCTION(GSList*, gs_local_free_slist, g_slist_free)
|
||||
GS_DEFINE_CLEANUP_FUNCTION0(GObject*, gs_local_obj_unref, g_object_unref)
|
||||
GS_DEFINE_CLEANUP_FUNCTION0(GPtrArray*, gs_local_ptrarray_unref, g_ptr_array_unref)
|
||||
GS_DEFINE_CLEANUP_FUNCTION0(GVariant*, gs_local_variant_unref, g_variant_unref)
|
||||
GS_DEFINE_CLEANUP_FUNCTION0(GVariantBuilder*, gs_local_variant_builder_unref, g_variant_builder_unref)
|
||||
GS_DEFINE_CLEANUP_FUNCTION0(GVariantIter*, gs_local_variant_iter_free, g_variant_iter_free)
|
||||
|
||||
GS_DEFINE_CLEANUP_FUNCTION(char**, gs_local_strfreev, g_strfreev)
|
||||
GS_DEFINE_CLEANUP_FUNCTION(void*, gs_local_free, g_free)
|
||||
|
||||
/**
|
||||
* gs_free:
|
||||
*
|
||||
* Call g_free() on a variable location when it goes out of scope.
|
||||
*/
|
||||
#define gs_free __attribute__ ((cleanup(gs_local_free)))
|
||||
|
||||
/**
|
||||
* gs_unref_object:
|
||||
*
|
||||
* Call g_object_unref() on a variable location when it goes out of
|
||||
* scope. Note that unlike g_object_unref(), the variable may be
|
||||
* %NULL.
|
||||
*/
|
||||
#define gs_unref_object __attribute__ ((cleanup(gs_local_obj_unref)))
|
||||
|
||||
/**
|
||||
* gs_unref_variant:
|
||||
*
|
||||
* Call g_variant_unref() on a variable location when it goes out of
|
||||
* scope. Note that unlike g_variant_unref(), the variable may be
|
||||
* %NULL.
|
||||
*/
|
||||
#define gs_unref_variant __attribute__ ((cleanup(gs_local_variant_unref)))
|
||||
|
||||
/**
|
||||
* gs_free_variant_iter:
|
||||
*
|
||||
* Call g_variant_iter_free() on a variable location when it goes out of
|
||||
* scope.
|
||||
*/
|
||||
#define gs_free_variant_iter __attribute__ ((cleanup(gs_local_variant_iter_free)))
|
||||
|
||||
/**
|
||||
* gs_free_variant_builder:
|
||||
*
|
||||
* Call g_variant_builder_unref() on a variable location when it goes out of
|
||||
* scope.
|
||||
*/
|
||||
#define gs_unref_variant_builder __attribute__ ((cleanup(gs_local_variant_builder_unref)))
|
||||
|
||||
/**
|
||||
* gs_unref_array:
|
||||
*
|
||||
* Call g_array_unref() on a variable location when it goes out of
|
||||
* scope. Note that unlike g_array_unref(), the variable may be
|
||||
* %NULL.
|
||||
|
||||
*/
|
||||
#define gs_unref_array __attribute__ ((cleanup(gs_local_array_unref)))
|
||||
|
||||
/**
|
||||
* gs_unref_ptrarray:
|
||||
*
|
||||
* Call g_ptr_array_unref() on a variable location when it goes out of
|
||||
* scope. Note that unlike g_ptr_array_unref(), the variable may be
|
||||
* %NULL.
|
||||
|
||||
*/
|
||||
#define gs_unref_ptrarray __attribute__ ((cleanup(gs_local_ptrarray_unref)))
|
||||
|
||||
/**
|
||||
* gs_unref_hashtable:
|
||||
*
|
||||
* Call g_hash_table_unref() on a variable location when it goes out
|
||||
* of scope. Note that unlike g_hash_table_unref(), the variable may
|
||||
* be %NULL.
|
||||
*/
|
||||
#define gs_unref_hashtable __attribute__ ((cleanup(gs_local_hashtable_unref)))
|
||||
|
||||
/**
|
||||
* gs_free_list:
|
||||
*
|
||||
* Call g_list_free() on a variable location when it goes out
|
||||
* of scope.
|
||||
*/
|
||||
#define gs_free_list __attribute__ ((cleanup(gs_local_free_list)))
|
||||
|
||||
/**
|
||||
* gs_free_slist:
|
||||
*
|
||||
* Call g_slist_free() on a variable location when it goes out
|
||||
* of scope.
|
||||
*/
|
||||
#define gs_free_slist __attribute__ ((cleanup(gs_local_free_slist)))
|
||||
|
||||
/**
|
||||
* gs_free_checksum:
|
||||
*
|
||||
* Call g_checksum_free() on a variable location when it goes out
|
||||
* of scope. Note that unlike g_checksum_free(), the variable may
|
||||
* be %NULL.
|
||||
*/
|
||||
#define gs_free_checksum __attribute__ ((cleanup(gs_local_checksum_free)))
|
||||
|
||||
/**
|
||||
* gs_unref_bytes:
|
||||
*
|
||||
* Call g_bytes_unref() on a variable location when it goes out
|
||||
* of scope. Note that unlike g_bytes_unref(), the variable may
|
||||
* be %NULL.
|
||||
*/
|
||||
#define gs_unref_bytes __attribute__ ((cleanup(gs_local_bytes_unref)))
|
||||
|
||||
/**
|
||||
* gs_strfreev:
|
||||
*
|
||||
* Call g_strfreev() on a variable location when it goes out of scope.
|
||||
*/
|
||||
#define gs_strfreev __attribute__ ((cleanup(gs_local_strfreev)))
|
||||
|
||||
/**
|
||||
* gs_free_error:
|
||||
*
|
||||
* Call g_error_free() on a variable location when it goes out of scope.
|
||||
*/
|
||||
#define gs_free_error __attribute__ ((cleanup(gs_local_free_error)))
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 856b8f9431a63c7807fb3859ed6de2a0f3abfb3b
|
|
@ -38,7 +38,6 @@ endif
|
|||
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir)/include \
|
||||
-I${top_srcdir}/libgsystem \
|
||||
-I$(top_srcdir)/libnm-util \
|
||||
-I$(top_builddir)/libnm-util \
|
||||
-I$(top_srcdir)/callouts \
|
||||
|
@ -58,7 +57,7 @@ sbin_PROGRAMS = NetworkManager
|
|||
NetworkManager_SOURCES = \
|
||||
main.c
|
||||
|
||||
NetworkManager_LDADD = libNetworkManager.la $(top_builddir)/libgsystem.la $(LIBNDP_LIBS)
|
||||
NetworkManager_LDADD = libNetworkManager.la $(LIBNDP_LIBS)
|
||||
|
||||
noinst_LTLIBRARIES = libNetworkManager.la
|
||||
|
||||
|
@ -356,7 +355,6 @@ libNetworkManager_la_SOURCES = \
|
|||
$(glue_sources)
|
||||
|
||||
libNetworkManager_la_LIBADD = \
|
||||
$(top_builddir)/libgsystem.la \
|
||||
$(top_builddir)/libnm-util/libnm-util.la \
|
||||
$(DBUS_LIBS) \
|
||||
$(GLIB_LIBS) \
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include <linux/if.h>
|
||||
#include <netlink/route/addr.h>
|
||||
|
||||
#include "libgsystem.h"
|
||||
#include "gsystem-local-alloc.h"
|
||||
#include "nm-glib-compat.h"
|
||||
#include "nm-device.h"
|
||||
#include "nm-device-private.h"
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#include <string.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
#include "libgsystem.h"
|
||||
#include "gsystem-local-alloc.h"
|
||||
#include "NetworkManager.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
#include "nm-manager.h"
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <unistd.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
|
||||
#include "libgsystem.h"
|
||||
#include "gsystem-local-alloc.h"
|
||||
|
||||
#include "nm-activation-request.h"
|
||||
#include "nm-logging.h"
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
#include "nm-ip4-config.h"
|
||||
|
||||
#include "libgsystem.h"
|
||||
#include "nm-platform.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-dbus-manager.h"
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "nm-ip6-config.h"
|
||||
|
||||
#include "nm-glib-compat.h"
|
||||
#include "libgsystem.h"
|
||||
#include "nm-platform.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-dbus-manager.h"
|
||||
|
|
|
@ -1537,17 +1537,6 @@ done:
|
|||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
/* This should really be moved to gsystem. */
|
||||
#define free_slist __attribute__ ((cleanup(local_slist_free)))
|
||||
static void
|
||||
local_slist_free (void *loc)
|
||||
{
|
||||
GSList **location = loc;
|
||||
|
||||
if (location)
|
||||
g_slist_free (*location);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
match_connection_filter (NMConnection *connection, gpointer user_data)
|
||||
{
|
||||
|
@ -1566,7 +1555,7 @@ static NMConnection *
|
|||
get_existing_connection (NMManager *manager, NMDevice *device)
|
||||
{
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
|
||||
free_slist GSList *connections = nm_manager_get_activatable_connections (manager);
|
||||
gs_free_slist GSList *connections = nm_manager_get_activatable_connections (manager);
|
||||
NMConnection *connection = NULL, *matched;
|
||||
NMSettingsConnection *added = NULL;
|
||||
GError *error = NULL;
|
||||
|
|
|
@ -543,7 +543,7 @@ link_get_master (NMPlatform *platform, int slave)
|
|||
static gboolean
|
||||
master_set_option (NMPlatform *platform, int master, const char *option, const char *value)
|
||||
{
|
||||
auto_g_free char *path = g_strdup_printf ("master:%d:%s", master, option);
|
||||
gs_free char *path = g_strdup_printf ("master:%d:%s", master, option);
|
||||
|
||||
return sysctl_set (platform, path, value);
|
||||
}
|
||||
|
@ -551,7 +551,7 @@ master_set_option (NMPlatform *platform, int master, const char *option, const c
|
|||
static char *
|
||||
master_get_option (NMPlatform *platform, int master, const char *option)
|
||||
{
|
||||
auto_g_free char *path = g_strdup_printf ("master:%d:%s", master, option);
|
||||
gs_free char *path = g_strdup_printf ("master:%d:%s", master, option);
|
||||
|
||||
return sysctl_get (platform, path);
|
||||
}
|
||||
|
@ -559,7 +559,7 @@ master_get_option (NMPlatform *platform, int master, const char *option)
|
|||
static gboolean
|
||||
slave_set_option (NMPlatform *platform, int slave, const char *option, const char *value)
|
||||
{
|
||||
auto_g_free char *path = g_strdup_printf ("slave:%d:%s", slave, option);
|
||||
gs_free char *path = g_strdup_printf ("slave:%d:%s", slave, option);
|
||||
|
||||
return sysctl_set (platform, path, value);
|
||||
}
|
||||
|
@ -567,7 +567,7 @@ slave_set_option (NMPlatform *platform, int slave, const char *option, const cha
|
|||
static char *
|
||||
slave_get_option (NMPlatform *platform, int slave, const char *option)
|
||||
{
|
||||
auto_g_free char *path = g_strdup_printf ("slave:%d:%s", slave, option);
|
||||
gs_free char *path = g_strdup_printf ("slave:%d:%s", slave, option);
|
||||
|
||||
return sysctl_get (platform, path);
|
||||
}
|
||||
|
|
|
@ -598,8 +598,8 @@ ethtool_get (const char *name, gpointer edata)
|
|||
static int
|
||||
ethtool_get_stringset_index (const char *ifname, int stringset_id, const char *string)
|
||||
{
|
||||
auto_g_free struct ethtool_sset_info *info = NULL;
|
||||
auto_g_free struct ethtool_gstrings *strings = NULL;
|
||||
gs_free struct ethtool_sset_info *info = NULL;
|
||||
gs_free struct ethtool_gstrings *strings = NULL;
|
||||
guint32 len, i;
|
||||
|
||||
info = g_malloc0 (sizeof (*info) + sizeof (guint32));
|
||||
|
@ -2472,7 +2472,7 @@ link_supports_vlans (NMPlatform *platform, int ifindex)
|
|||
{
|
||||
auto_nl_object struct rtnl_link *rtnllink = link_get (platform, ifindex);
|
||||
const char *name = nm_platform_link_get_name (ifindex);
|
||||
auto_g_free struct ethtool_gfeatures *features = NULL;
|
||||
gs_free struct ethtool_gfeatures *features = NULL;
|
||||
int idx, block, bit, size;
|
||||
|
||||
/* Only ARPHRD_ETHER links can possibly support VLANs. */
|
||||
|
@ -2684,7 +2684,7 @@ link_option_path (int master, const char *category, const char *option)
|
|||
static gboolean
|
||||
link_set_option (int master, const char *category, const char *option, const char *value)
|
||||
{
|
||||
auto_g_free char *path = link_option_path (master, category, option);
|
||||
gs_free char *path = link_option_path (master, category, option);
|
||||
|
||||
return path && nm_platform_sysctl_set (path, value);
|
||||
}
|
||||
|
@ -2692,7 +2692,7 @@ link_set_option (int master, const char *category, const char *option, const cha
|
|||
static char *
|
||||
link_get_option (int master, const char *category, const char *option)
|
||||
{
|
||||
auto_g_free char *path = link_option_path (master, category, option);
|
||||
gs_free char *path = link_option_path (master, category, option);
|
||||
|
||||
return path ? nm_platform_sysctl_get (path) : NULL;
|
||||
}
|
||||
|
@ -2771,7 +2771,7 @@ infiniband_partition_add (NMPlatform *platform, int parent, int p_key)
|
|||
g_free (path);
|
||||
|
||||
if (success) {
|
||||
auto_g_free char *ifname = g_strdup_printf ("%s.%04x", parent_name, p_key);
|
||||
gs_free char *ifname = g_strdup_printf ("%s.%04x", parent_name, p_key);
|
||||
auto_nl_object struct rtnl_link *rtnllink = _nm_rtnl_link_alloc (0, ifname);
|
||||
|
||||
success = refresh_object (platform, (struct nl_object *) rtnllink, FALSE, NM_PLATFORM_REASON_INTERNAL);
|
||||
|
@ -2784,7 +2784,7 @@ static gboolean
|
|||
veth_get_properties (NMPlatform *platform, int ifindex, NMPlatformVethProperties *props)
|
||||
{
|
||||
const char *ifname;
|
||||
auto_g_free struct ethtool_stats *stats = NULL;
|
||||
gs_free struct ethtool_stats *stats = NULL;
|
||||
int peer_ifindex_stat;
|
||||
|
||||
ifname = nm_platform_link_get_name (ifindex);
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <linux/if_addr.h>
|
||||
|
||||
#include <NetworkManager.h>
|
||||
#include "gsystem-local-alloc.h"
|
||||
|
||||
#define NM_TYPE_PLATFORM (nm_platform_get_type ())
|
||||
#define NM_PLATFORM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_PLATFORM, NMPlatform))
|
||||
|
@ -624,11 +625,4 @@ void nm_platform_addr_flags2str (int flags, char *buf, size_t size);
|
|||
|
||||
int nm_platform_ip_address_cmp_expiry (const NMPlatformIPAddress *a, const NMPlatformIPAddress *b);
|
||||
|
||||
#define auto_g_free __attribute__((cleanup(put_g_free)))
|
||||
static void __attribute__((unused))
|
||||
put_g_free (void *ptr)
|
||||
{
|
||||
g_clear_pointer ((gpointer *) ptr, g_free);
|
||||
}
|
||||
|
||||
#endif /* NM_PLATFORM_H */
|
||||
|
|
|
@ -47,7 +47,7 @@ do_sysctl_set (char **argv)
|
|||
static gboolean
|
||||
do_sysctl_get (char **argv)
|
||||
{
|
||||
auto_g_free char *value = nm_platform_sysctl_get (argv[0]);
|
||||
gs_free char *value = nm_platform_sysctl_get (argv[0]);
|
||||
|
||||
printf ("%s\n", value);
|
||||
|
||||
|
@ -281,7 +281,7 @@ do_master_get_option (char **argv)
|
|||
{
|
||||
int ifindex = parse_ifindex (*argv++);
|
||||
const char *option = *argv++;
|
||||
auto_g_free char *value = nm_platform_master_get_option (ifindex, option);
|
||||
gs_free char *value = nm_platform_master_get_option (ifindex, option);
|
||||
|
||||
printf ("%s\n", value);
|
||||
|
||||
|
@ -303,7 +303,7 @@ do_slave_get_option (char **argv)
|
|||
{
|
||||
int ifindex = parse_ifindex (*argv++);
|
||||
const char *option = *argv++;
|
||||
auto_g_free char *value = nm_platform_slave_get_option (ifindex, option);
|
||||
gs_free char *value = nm_platform_slave_get_option (ifindex, option);
|
||||
|
||||
printf ("%s\n", value);
|
||||
|
||||
|
|
Loading…
Reference in a new issue