all: use stack-allocated uuid at various places

No need to create a UUID on the heap in this case.
This commit is contained in:
Thomas Haller
2017-02-28 16:05:39 +01:00
parent cf213216fd
commit 72bfe62a9a
4 changed files with 15 additions and 16 deletions

View File

@@ -602,17 +602,17 @@ static gboolean
_normalize_connection_uuid (NMConnection *self) _normalize_connection_uuid (NMConnection *self)
{ {
NMSettingConnection *s_con = nm_connection_get_setting_connection (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)) if (nm_setting_connection_get_uuid (s_con))
return FALSE; return FALSE;
uuid = nm_utils_uuid_generate (); g_object_set (s_con,
g_object_set (s_con, NM_SETTING_CONNECTION_UUID, uuid, NULL); NM_SETTING_CONNECTION_UUID,
g_free (uuid); nm_utils_uuid_generate_buf (uuid),
NULL);
return TRUE; return TRUE;
} }

View File

@@ -217,7 +217,7 @@ nm_utils_complete_generic (NMPlatform *platform,
gboolean default_enable_ipv6) gboolean default_enable_ipv6)
{ {
NMSettingConnection *s_con; NMSettingConnection *s_con;
char *id, *uuid, *ifname; char *id, *ifname;
GHashTable *parameters; GHashTable *parameters;
g_assert (fallback_id_prefix); 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); g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_TYPE, ctype, NULL);
if (!nm_setting_connection_get_uuid (s_con)) { if (!nm_setting_connection_get_uuid (s_con)) {
uuid = nm_utils_uuid_generate (); char uuid[37];
g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_UUID, uuid, NULL);
g_free (uuid); g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_buf (uuid), NULL);
} }
/* Add a connection ID if absent */ /* Add a connection ID if absent */

View File

@@ -183,7 +183,8 @@ pan_connection_check_create (NMBluezDevice *self)
NMConnection *connection; NMConnection *connection;
NMConnection *added; NMConnection *added;
NMSetting *setting; NMSetting *setting;
char *uuid, *id; char *id;
char uuid[37];
GError *error = NULL; GError *error = NULL;
NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE (self); NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE (self);
@@ -205,7 +206,7 @@ pan_connection_check_create (NMBluezDevice *self)
connection = nm_simple_connection_new (); connection = nm_simple_connection_new ();
/* Setting: Connection */ /* Setting: Connection */
uuid = nm_utils_uuid_generate (); nm_utils_uuid_generate_buf (uuid);
id = g_strdup_printf (_("%s Network"), priv->name); id = g_strdup_printf (_("%s Network"), priv->name);
setting = nm_setting_connection_new (); setting = nm_setting_connection_new ();
g_object_set (setting, g_object_set (setting,
@@ -266,7 +267,6 @@ pan_connection_check_create (NMBluezDevice *self)
g_object_unref (connection); g_object_unref (connection);
g_free (id); g_free (id);
g_free (uuid);
} }
static gboolean static gboolean

View File

@@ -3629,7 +3629,7 @@ nm_device_generate_connection (NMDevice *self, NMDevice *master)
NMSetting *s_con; NMSetting *s_con;
NMSetting *s_ip4; NMSetting *s_ip4;
NMSetting *s_ip6; NMSetting *s_ip6;
gs_free char *uuid = NULL; char uuid[37];
const char *ip4_method, *ip6_method; const char *ip4_method, *ip6_method;
GError *error = NULL; GError *error = NULL;
const NMPlatformLink *pllink; const NMPlatformLink *pllink;
@@ -3646,10 +3646,9 @@ nm_device_generate_connection (NMDevice *self, NMDevice *master)
connection = nm_simple_connection_new (); connection = nm_simple_connection_new ();
s_con = nm_setting_connection_new (); s_con = nm_setting_connection_new ();
uuid = nm_utils_uuid_generate ();
g_object_set (s_con, 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_ID, ifname,
NM_SETTING_CONNECTION_AUTOCONNECT, FALSE, NM_SETTING_CONNECTION_AUTOCONNECT, FALSE,
NM_SETTING_CONNECTION_INTERFACE_NAME, ifname, NM_SETTING_CONNECTION_INTERFACE_NAME, ifname,