summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-02-28 16:05:39 +0100
committerThomas Haller <thaller@redhat.com>2017-03-02 12:14:29 +0100
commit72bfe62a9add5fa78bbcbf8bf549605d22c43bcc (patch)
treedadda7a06c3a94fffacd864ddcca41810c6b714f
parentcf213216fd968b9b2de59bd012d1a7f536908b21 (diff)
downloadNetworkManager-72bfe62a9add5fa78bbcbf8bf549605d22c43bcc.tar.gz
all: use stack-allocated uuid at various places
No need to create a UUID on the heap in this case.
-rw-r--r--libnm-core/nm-connection.c12
-rw-r--r--src/NetworkManagerUtils.c8
-rw-r--r--src/devices/bluetooth/nm-bluez-device.c6
-rw-r--r--src/devices/nm-device.c5
4 files changed, 15 insertions, 16 deletions
diff --git a/libnm-core/nm-connection.c b/libnm-core/nm-connection.c
index 08edec70c8..4a73e8537d 100644
--- a/libnm-core/nm-connection.c
+++ b/libnm-core/nm-connection.c
@@ -602,17 +602,17 @@ static gboolean
_normalize_connection_uuid (NMConnection *self)
{
NMSettingConnection *s_con = nm_connection_get_setting_connection (self);
- char *uuid;
+ char uuid[37];
- g_assert (s_con);
+ nm_assert (s_con);
if (nm_setting_connection_get_uuid (s_con))
return FALSE;
- uuid = nm_utils_uuid_generate ();
- g_object_set (s_con, NM_SETTING_CONNECTION_UUID, uuid, NULL);
- g_free (uuid);
-
+ g_object_set (s_con,
+ NM_SETTING_CONNECTION_UUID,
+ nm_utils_uuid_generate_buf (uuid),
+ NULL);
return TRUE;
}
diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c
index 55b660db83..20b871622e 100644
--- a/src/NetworkManagerUtils.c
+++ b/src/NetworkManagerUtils.c
@@ -217,7 +217,7 @@ nm_utils_complete_generic (NMPlatform *platform,
gboolean default_enable_ipv6)
{
NMSettingConnection *s_con;
- char *id, *uuid, *ifname;
+ char *id, *ifname;
GHashTable *parameters;
g_assert (fallback_id_prefix);
@@ -230,9 +230,9 @@ nm_utils_complete_generic (NMPlatform *platform,
g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_TYPE, ctype, NULL);
if (!nm_setting_connection_get_uuid (s_con)) {
- uuid = nm_utils_uuid_generate ();
- g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_UUID, uuid, NULL);
- g_free (uuid);
+ char uuid[37];
+
+ g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_buf (uuid), NULL);
}
/* Add a connection ID if absent */
diff --git a/src/devices/bluetooth/nm-bluez-device.c b/src/devices/bluetooth/nm-bluez-device.c
index 92b2c91895..ebfa0d647e 100644
--- a/src/devices/bluetooth/nm-bluez-device.c
+++ b/src/devices/bluetooth/nm-bluez-device.c
@@ -183,7 +183,8 @@ pan_connection_check_create (NMBluezDevice *self)
NMConnection *connection;
NMConnection *added;
NMSetting *setting;
- char *uuid, *id;
+ char *id;
+ char uuid[37];
GError *error = NULL;
NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE (self);
@@ -205,7 +206,7 @@ pan_connection_check_create (NMBluezDevice *self)
connection = nm_simple_connection_new ();
/* Setting: Connection */
- uuid = nm_utils_uuid_generate ();
+ nm_utils_uuid_generate_buf (uuid);
id = g_strdup_printf (_("%s Network"), priv->name);
setting = nm_setting_connection_new ();
g_object_set (setting,
@@ -266,7 +267,6 @@ pan_connection_check_create (NMBluezDevice *self)
g_object_unref (connection);
g_free (id);
- g_free (uuid);
}
static gboolean
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index a0a5ed2aec..ef96243b2f 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -3629,7 +3629,7 @@ nm_device_generate_connection (NMDevice *self, NMDevice *master)
NMSetting *s_con;
NMSetting *s_ip4;
NMSetting *s_ip6;
- gs_free char *uuid = NULL;
+ char uuid[37];
const char *ip4_method, *ip6_method;
GError *error = NULL;
const NMPlatformLink *pllink;
@@ -3646,10 +3646,9 @@ nm_device_generate_connection (NMDevice *self, NMDevice *master)
connection = nm_simple_connection_new ();
s_con = nm_setting_connection_new ();
- uuid = nm_utils_uuid_generate ();
g_object_set (s_con,
- NM_SETTING_CONNECTION_UUID, uuid,
+ NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_buf (uuid),
NM_SETTING_CONNECTION_ID, ifname,
NM_SETTING_CONNECTION_AUTOCONNECT, FALSE,
NM_SETTING_CONNECTION_INTERFACE_NAME, ifname,