summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-07-15 20:18:15 +0200
committerThomas Haller <thaller@redhat.com>2014-07-15 22:50:36 +0200
commit6cf9724f7d8b25ba898c3cca4f8bdd32415b8f73 (patch)
tree61cddfc224dfee06c3375a8b940641b2a8db541b
parent37f08bc84843e71bb4859d84bea9b8dd7e0d09dd (diff)
downloadNetworkManager-6cf9724f7d8b25ba898c3cca4f8bdd32415b8f73.tar.gz
platform: use gs_free (instead of own define auto_g_free)
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--src/platform/nm-fake-platform.c8
-rw-r--r--src/platform/nm-linux-platform.c14
-rw-r--r--src/platform/nm-platform.h8
-rw-r--r--src/platform/tests/platform.c6
4 files changed, 15 insertions, 21 deletions
diff --git a/src/platform/nm-fake-platform.c b/src/platform/nm-fake-platform.c
index 46272217d0..4cbfd7854c 100644
--- a/src/platform/nm-fake-platform.c
+++ b/src/platform/nm-fake-platform.c
@@ -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);
}
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index 0b10afd2ae..ec0bd7521a 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -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);
diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h
index 96b6cfabbd..9bdc6a9cb1 100644
--- a/src/platform/nm-platform.h
+++ b/src/platform/nm-platform.h
@@ -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 */
diff --git a/src/platform/tests/platform.c b/src/platform/tests/platform.c
index ea8bd0e3b3..8a680c521b 100644
--- a/src/platform/tests/platform.c
+++ b/src/platform/tests/platform.c
@@ -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);