network: Use g_autofree for strings

This commit is contained in:
Robert Ancell 2019-09-12 11:40:48 +12:00
parent b085a8af51
commit de84f7e344
23 changed files with 115 additions and 204 deletions

View file

@ -277,7 +277,7 @@ panel_refresh_device_titles (CcNetworkPanel *panel)
GPtrArray *ndarray, *nmdarray;
NetDevice **devices;
NMDevice **nm_devices, *nm_device;
gchar **titles;
g_auto(GStrv) titles = NULL;
gint i, num_devices;
ndarray = cc_network_panel_get_devices (panel);
@ -311,9 +311,7 @@ panel_refresh_device_titles (CcNetworkPanel *panel)
net_object_set_title (NET_OBJECT (devices[i]), bt_name);
else
net_object_set_title (NET_OBJECT (devices[i]), titles[i]);
g_free (titles[i]);
}
g_free (titles);
g_ptr_array_free (ndarray, TRUE);
g_ptr_array_free (nmdarray, TRUE);
}
@ -698,7 +696,7 @@ static void
panel_add_vpn_device (CcNetworkPanel *panel, NMConnection *connection)
{
GtkWidget *stack;
gchar *title;
g_autofree gchar *title = NULL;
NetVpn *net_vpn;
const gchar *id;
@ -729,8 +727,6 @@ panel_add_vpn_device (CcNetworkPanel *panel, NMConnection *connection)
/* store in the devices array */
g_ptr_array_add (panel->devices, net_vpn);
g_free (title);
/* update vpn widgets */
update_vpn_section (panel);
}
@ -771,14 +767,15 @@ notify_connection_added_cb (NMClient *client,
static void
panel_check_network_manager_version (CcNetworkPanel *panel)
{
GtkWidget *box;
GtkWidget *label;
gchar *markup;
const gchar *version;
/* parse running version */
version = nm_client_get_version (panel->client);
if (version == NULL) {
GtkWidget *box;
GtkWidget *label;
g_autofree gchar *markup = NULL;
gtk_container_remove (GTK_CONTAINER (panel), gtk_bin_get_child (GTK_BIN (panel)));
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 20);
@ -800,7 +797,6 @@ panel_check_network_manager_version (CcNetworkPanel *panel)
gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
gtk_widget_show_all (box);
g_free (markup);
} else {
manager_running (panel->client, NULL, panel);
}

View file

@ -79,7 +79,7 @@ get_ap_security_string (NMAccessPoint *ap)
static void
update_last_used (CEPageDetails *page, NMConnection *connection)
{
gchar *last_used = NULL;
g_autofree gchar *last_used = NULL;
GDateTime *now = NULL;
GDateTime *then = NULL;
gint days;
@ -114,7 +114,6 @@ out:
g_date_time_unref (now);
if (then != NULL)
g_date_time_unref (then);
g_free (last_used);
}
static void

View file

@ -85,8 +85,8 @@ connect_ethernet_page (CEPageEthernet *page)
static void
ui_to_setting (CEPageEthernet *page)
{
gchar *device_mac = NULL;
gchar *cloned_mac = NULL;
g_autofree gchar *device_mac = NULL;
g_autofree gchar *cloned_mac = NULL;
const gchar *text;
GtkWidget *entry;
GtkComboBoxText *combo;
@ -109,9 +109,6 @@ ui_to_setting (CEPageEthernet *page)
g_object_set (page->setting_connection,
NM_SETTING_CONNECTION_ID, gtk_entry_get_text (page->name),
NULL);
g_free (cloned_mac);
g_free (device_mac);
}
static gboolean

View file

@ -404,9 +404,8 @@ add_route_row (CEPageIP4 *page,
g_signal_connect_swapped (widget, "activate", G_CALLBACK (ensure_empty_routes_row), page);
g_object_set_data (G_OBJECT (row), "metric", widget);
if (metric >= 0) {
gchar *s = g_strdup_printf ("%d", metric);
g_autofree gchar *s = g_strdup_printf ("%d", metric);
gtk_entry_set_text (GTK_ENTRY (widget), s);
g_free (s);
}
gtk_entry_set_width_chars (GTK_ENTRY (widget), 5);
gtk_widget_set_hexpand (widget, TRUE);

View file

@ -277,13 +277,12 @@ add_address_section (CEPageIP6 *page)
for (i = 0; i < nm_setting_ip_config_get_num_addresses (page->setting); i++) {
NMIPAddress *addr;
char *netmask;
g_autofree gchar *netmask = NULL;
addr = nm_setting_ip_config_get_address (page->setting, i);
netmask = g_strdup_printf ("%u", nm_ip_address_get_prefix (addr));
add_address_row (page, nm_ip_address_get_address (addr), netmask,
i == 0 ? nm_setting_ip_config_get_gateway (page->setting) : NULL);
g_free (netmask);
}
if (nm_setting_ip_config_get_num_addresses (page->setting) == 0)
ensure_empty_address_row (page);
@ -448,7 +447,8 @@ add_routes_section (CEPageIP6 *page)
for (i = 0; i < nm_setting_ip_config_get_num_routes (page->setting); i++) {
NMIPRoute *route;
char *prefix, *metric;
g_autofree gchar *prefix = NULL;
g_autofree gchar *metric = NULL;
route = nm_setting_ip_config_get_route (page->setting, i);
prefix = g_strdup_printf ("%u", nm_ip_route_get_prefix (route));
@ -457,8 +457,6 @@ add_routes_section (CEPageIP6 *page)
prefix,
nm_ip_route_get_next_hop (route),
metric);
g_free (prefix);
g_free (metric);
}
if (nm_setting_ip_config_get_num_routes (page->setting) == 0)
add_empty_route_row (page);

View file

@ -55,7 +55,7 @@ vpn_gnome3ify_editor (GtkWidget *widget)
} else if (GTK_IS_LABEL (widget)) {
const char *text;
gfloat xalign;
char *newtext;
g_autofree gchar *newtext = NULL;
int len;
xalign = gtk_label_get_xalign (GTK_LABEL (widget));
@ -68,7 +68,6 @@ vpn_gnome3ify_editor (GtkWidget *widget)
newtext = g_strndup (text, len - 1);
gtk_label_set_text (GTK_LABEL (widget), newtext);
g_free (newtext);
gtk_label_set_xalign (GTK_LABEL (widget), 1.0);
}
}

View file

@ -38,7 +38,7 @@ connect_wifi_page (CEPageWifi *page)
{
GtkWidget *widget;
GBytes *ssid;
gchar *utf8_ssid;
g_autofree gchar *utf8_ssid = NULL;
GPtrArray *bssid_array;
gchar **bssid_list;
const char *s_bssid_str;
@ -56,7 +56,6 @@ connect_wifi_page (CEPageWifi *page)
else
utf8_ssid = g_strdup ("");
gtk_entry_set_text (GTK_ENTRY (widget), utf8_ssid);
g_free (utf8_ssid);
g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
@ -98,7 +97,8 @@ ui_to_setting (CEPageWifi *page)
const gchar *utf8_ssid, *bssid;
GtkWidget *entry;
GtkComboBoxText *combo;
char *device_mac, *cloned_mac;
g_autofree gchar *device_mac = NULL;
g_autofree gchar *cloned_mac = NULL;
entry = GTK_WIDGET (gtk_builder_get_object (CE_PAGE (page)->builder, "entry_ssid"));
utf8_ssid = gtk_entry_get_text (GTK_ENTRY (entry));
@ -125,8 +125,6 @@ ui_to_setting (CEPageWifi *page)
if (ssid)
g_bytes_unref (ssid);
g_free (cloned_mac);
g_free (device_mac);
}
static gboolean

View file

@ -326,7 +326,8 @@ ce_page_get_mac_list (NMClient *client,
for (i = 0; devices && (i < devices->len); i++) {
NMDevice *dev = g_ptr_array_index (devices, i);
const char *iface;
char *mac, *item;
g_autofree gchar *mac = NULL;
g_autofree gchar *item = NULL;
if (!G_TYPE_CHECK_INSTANCE_TYPE (dev, device_type))
continue;
@ -334,8 +335,7 @@ ce_page_get_mac_list (NMClient *client,
g_object_get (G_OBJECT (dev), mac_property, &mac, NULL);
iface = nm_device_get_iface (NM_DEVICE (dev));
item = g_strdup_printf ("%s (%s)", mac, iface);
g_free (mac);
g_ptr_array_add (macs, item);
g_ptr_array_add (macs, g_steal_pointer (&item));
}
g_ptr_array_add (macs, NULL);
@ -443,7 +443,7 @@ ce_page_address_is_valid (const gchar *addr)
{0x00, 0x30, 0xb4, 0x00, 0x00, 0x00}, /* prism54 dummy MAC */
};
guint8 addr_bin[ETH_ALEN];
char *trimmed_addr;
g_autofree gchar *trimmed_addr = NULL;
guint i;
if (!addr || *addr == '\0')
@ -451,17 +451,11 @@ ce_page_address_is_valid (const gchar *addr)
trimmed_addr = ce_page_trim_address (addr);
if (!nm_utils_hwaddr_valid (trimmed_addr, -1)) {
g_free (trimmed_addr);
if (!nm_utils_hwaddr_valid (trimmed_addr, -1))
return FALSE;
}
if (!nm_utils_hwaddr_aton (trimmed_addr, addr_bin, ETH_ALEN)) {
g_free (trimmed_addr);
if (!nm_utils_hwaddr_aton (trimmed_addr, addr_bin, ETH_ALEN))
return FALSE;
}
g_free (trimmed_addr);
/* Check for multicast address */
if ((((guint8 *) addr_bin)[0]) & 0x01)
@ -531,7 +525,7 @@ ce_spin_output_with_default (GtkSpinButton *spin, gpointer user_data)
{
gint defvalue = GPOINTER_TO_INT (user_data);
gint val;
gchar *buf = NULL;
g_autofree gchar *buf = NULL;
val = gtk_spin_button_get_value_as_int (spin);
if (val == defvalue)
@ -542,7 +536,6 @@ ce_spin_output_with_default (GtkSpinButton *spin, gpointer user_data)
if (strcmp (buf, gtk_entry_get_text (GTK_ENTRY (spin))))
gtk_entry_set_text (GTK_ENTRY (spin), buf);
g_free (buf);
return TRUE;
}
@ -567,7 +560,7 @@ ce_page_get_next_available_name (const GPtrArray *connections,
/* Find the next available unique connection name */
while (!cname && (i++ < 10000)) {
gchar *temp;
g_autofree gchar *temp = NULL;
gboolean found = FALSE;
switch (format) {
@ -588,9 +581,7 @@ ce_page_get_next_available_name (const GPtrArray *connections,
}
}
if (!found)
cname = temp;
else
g_free (temp);
cname = g_steal_pointer (&temp);
}
g_slist_free (names);

View file

@ -241,7 +241,7 @@ net_connection_editor_error_dialog (NetConnectionEditor *editor,
static void
net_connection_editor_do_fallback (NetConnectionEditor *editor, const gchar *type)
{
gchar *cmdline;
g_autofree gchar *cmdline = NULL;
g_autoptr(GError) error = NULL;
if (editor->is_new_connection) {
@ -252,7 +252,6 @@ net_connection_editor_do_fallback (NetConnectionEditor *editor, const gchar *typ
}
g_spawn_command_line_async (cmdline, &error);
g_free (cmdline);
if (error)
net_connection_editor_error_dialog (editor,
@ -265,7 +264,7 @@ net_connection_editor_do_fallback (NetConnectionEditor *editor, const gchar *typ
static void
net_connection_editor_update_title (NetConnectionEditor *editor)
{
gchar *id;
g_autofree gchar *id = NULL;
if (editor->title_set)
return;
@ -289,7 +288,6 @@ net_connection_editor_update_title (NetConnectionEditor *editor)
}
}
gtk_window_set_title (GTK_WINDOW (editor), id);
g_free (id);
}
static gboolean
@ -561,23 +559,21 @@ complete_vpn_connection (NetConnectionEditor *editor, NMConnection *connection)
}
if (!nm_setting_connection_get_uuid (s_con)) {
gchar *uuid = nm_utils_uuid_generate ();
g_autofree gchar *uuid = nm_utils_uuid_generate ();
g_object_set (s_con,
NM_SETTING_CONNECTION_UUID, uuid,
NULL);
g_free (uuid);
}
if (!nm_setting_connection_get_id (s_con)) {
const GPtrArray *connections;
gchar *id;
g_autofree gchar *id = NULL;
connections = nm_client_get_connections (editor->client);
id = ce_page_get_next_available_name (connections, NAME_FORMAT_TYPE, _("VPN"));
g_object_set (s_con,
NM_SETTING_CONNECTION_ID, id,
NULL);
g_free (id);
}
s_type = nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
@ -670,7 +666,10 @@ select_vpn_type (NetConnectionEditor *editor, GtkListBox *list)
/* Add the VPN types */
for (iter = vpn_plugins; iter; iter = iter->next) {
NMVpnEditorPlugin *plugin = nm_vpn_plugin_info_get_editor_plugin (iter->data);
char *name, *desc, *desc_markup, *service_name;
g_autofree gchar *name = NULL;
g_autofree gchar *desc = NULL;
g_autofree gchar *desc_markup = NULL;
g_autofree gchar *service_name = NULL;
GtkStyleContext *context;
g_object_get (plugin,
@ -700,13 +699,9 @@ select_vpn_type (NetConnectionEditor *editor, GtkListBox *list)
gtk_style_context_add_class (context, "dim-label");
gtk_box_pack_start (GTK_BOX (row_box), desc_label, FALSE, TRUE, 0);
g_free (name);
g_free (desc);
g_free (desc_markup);
gtk_container_add (GTK_CONTAINER (row), row_box);
gtk_widget_show_all (row);
g_object_set_data_full (G_OBJECT (row), "service_name", service_name, g_free);
g_object_set_data_full (G_OBJECT (row), "service_name", g_steal_pointer (&service_name), g_free);
gtk_container_add (GTK_CONTAINER (list), row);
}

View file

@ -106,7 +106,7 @@ typedef struct {
static void
import_vpn_from_file_cb (GtkWidget *dialog, gint response, gpointer user_data)
{
char *filename = NULL;
g_autofree gchar *filename = NULL;
ActionInfo *info = (ActionInfo *) user_data;
NMConnection *connection = NULL;
g_autoptr(GError) error = NULL;
@ -131,7 +131,7 @@ import_vpn_from_file_cb (GtkWidget *dialog, gint response, gpointer user_data)
if (!connection) {
GtkWidget *err_dialog;
char *bname = g_path_get_basename (filename);
g_autofree gchar *bname = g_path_get_basename (filename);
err_dialog = gtk_message_dialog_new (GTK_WINDOW (dialog),
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
@ -141,12 +141,10 @@ import_vpn_from_file_cb (GtkWidget *dialog, gint response, gpointer user_data)
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (err_dialog),
_("The file “%s” could not be read or does not contain recognized VPN connection information\n\nError: %s."),
bname, error ? error->message : "unknown error");
g_free (bname);
g_signal_connect (err_dialog, "delete-event", G_CALLBACK (gtk_widget_destroy), NULL);
g_signal_connect (err_dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
gtk_dialog_run (GTK_DIALOG (err_dialog));
}
g_free (filename);
out:
gtk_widget_hide (dialog);
@ -218,7 +216,7 @@ export_vpn_to_file_cb (GtkWidget *dialog, gint response, gpointer user_data)
if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
int replace_response;
GtkWidget *replace_dialog;
char *bname;
g_autofree gchar *bname = NULL;
bname = g_path_get_basename (filename);
replace_dialog = gtk_message_dialog_new (NULL,
@ -230,7 +228,6 @@ export_vpn_to_file_cb (GtkWidget *dialog, gint response, gpointer user_data)
gtk_dialog_add_buttons (GTK_DIALOG (replace_dialog), _("_Replace"), GTK_RESPONSE_OK, NULL);
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (replace_dialog),
_("Do you want to replace %s with the VPN connection you are saving?"), bname);
g_free (bname);
replace_response = gtk_dialog_run (GTK_DIALOG (replace_dialog));
gtk_widget_destroy (replace_dialog);
if (replace_response != GTK_RESPONSE_OK)
@ -259,7 +256,7 @@ export_vpn_to_file_cb (GtkWidget *dialog, gint response, gpointer user_data)
done:
if (!success) {
GtkWidget *err_dialog;
char *bname = filename ? g_path_get_basename (filename) : g_strdup ("(none)");
g_autofree gchar *bname = filename ? g_path_get_basename (filename) : g_strdup ("(none)");
err_dialog = gtk_message_dialog_new (NULL,
GTK_DIALOG_DESTROY_WITH_PARENT,
@ -269,7 +266,6 @@ done:
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (err_dialog),
_("The VPN connection “%s” could not be exported to %s.\n\nError: %s."),
id ? id : "(unknown)", bname, error ? error->message : "unknown error");
g_free (bname);
g_signal_connect (err_dialog, "delete-event", G_CALLBACK (gtk_widget_destroy), NULL);
g_signal_connect (err_dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
gtk_widget_show_all (err_dialog);
@ -311,13 +307,11 @@ vpn_export (NMConnection *connection)
plugin = vpn_get_plugin_by_service (service_type);
if (plugin) {
char *suggested = NULL;
g_autofree gchar *suggested = NULL;
suggested = nm_vpn_editor_plugin_get_suggested_filename (plugin, connection);
if (suggested) {
if (suggested)
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), suggested);
g_free (suggested);
}
}
g_signal_connect (G_OBJECT (dialog), "close", G_CALLBACK (gtk_widget_destroy), NULL);

View file

@ -149,10 +149,10 @@ add_details (GtkWidget *details, NMDevice *device, NMConnection *connection)
{
NMIPConfig *ip4_config = NULL;
NMIPConfig *ip6_config = NULL;
gchar *ip4_address = NULL;
gchar *ip4_route = NULL;
gchar *ip4_dns = NULL;
gchar *ip6_address = NULL;
g_autofree gchar *ip4_address = NULL;
g_autofree gchar *ip4_route = NULL;
g_autofree gchar *ip4_dns = NULL;
g_autofree gchar *ip6_address = NULL;
gint i = 0;
ip4_config = nm_device_get_ip4_config (device);
@ -184,16 +184,10 @@ add_details (GtkWidget *details, NMDevice *device, NMConnection *connection)
add_details_row (details, i++, _("DNS"), ip4_dns);
if (nm_device_get_state (device) != NM_DEVICE_STATE_ACTIVATED) {
gchar *last_used;
g_autofree gchar *last_used = NULL;
last_used = get_last_used_string (connection);
add_details_row (details, i++, _("Last used"), last_used);
g_free (last_used);
}
g_free (ip4_address);
g_free (ip4_route);
g_free (ip4_dns);
g_free (ip6_address);
}
static void populate_ui (NetDeviceEthernet *device);
@ -437,7 +431,8 @@ add_profile (GtkButton *button, NetDeviceEthernet *device)
{
NMConnection *connection;
NMSettingConnection *sc;
gchar *uuid, *id;
g_autofree gchar *uuid = NULL;
g_autofree gchar *id = NULL;
NetConnectionEditor *editor;
GtkWidget *window;
NMClient *client;
@ -463,9 +458,6 @@ add_profile (GtkButton *button, NetDeviceEthernet *device)
nm_connection_add_setting (connection, nm_setting_wired_new ());
g_free (uuid);
g_free (id);
window = gtk_widget_get_toplevel (GTK_WIDGET (button));
nmdev = net_device_get_nm_device (NET_DEVICE (device));

View file

@ -105,7 +105,7 @@ static void
mobile_connection_changed_cb (GtkComboBox *combo_box, NetDeviceMobile *device_mobile)
{
gboolean ret;
gchar *object_path = NULL;
g_autofree gchar *object_path = NULL;
GtkTreeIter iter;
GtkTreeModel *model;
NMConnection *connection;
@ -115,15 +115,15 @@ mobile_connection_changed_cb (GtkComboBox *combo_box, NetDeviceMobile *device_mo
GtkWidget *toplevel;
if (device_mobile->updating_device)
goto out;
return;
ret = gtk_combo_box_get_active_iter (combo_box, &iter);
if (!ret)
goto out;
return;
device = net_device_get_nm_device (NET_DEVICE (device_mobile));
if (device == NULL)
goto out;
return;
client = net_object_get_client (NET_OBJECT (device_mobile));
/* get entry */
@ -137,7 +137,7 @@ mobile_connection_changed_cb (GtkComboBox *combo_box, NetDeviceMobile *device_mo
cc_network_panel_connect_to_3g_network (toplevel,
client,
device);
goto out;
return;
}
/* activate the connection */
@ -150,10 +150,8 @@ mobile_connection_changed_cb (GtkComboBox *combo_box, NetDeviceMobile *device_mo
device, NULL, NULL,
connection_activate_cb,
device_mobile);
goto out;
return;
}
out:
g_free (object_path);
}
static void
@ -308,7 +306,7 @@ static void
device_mobile_refresh_operator_name (NetDeviceMobile *device_mobile)
{
if (device_mobile->mm_object != NULL) {
gchar *operator_name = NULL;
g_autofree gchar *operator_name = NULL;
MMModem3gpp *modem_3gpp;
MMModemCdma *modem_cdma;
@ -344,7 +342,6 @@ device_mobile_refresh_operator_name (NetDeviceMobile *device_mobile)
}
panel_set_device_widget_details (device_mobile->builder, "provider", operator_name);
g_free (operator_name);
} else {
const gchar *gsm;
const gchar *cdma;
@ -356,11 +353,8 @@ device_mobile_refresh_operator_name (NetDeviceMobile *device_mobile)
"ControlCenter::OperatorNameCdma");
if (gsm != NULL && cdma != NULL) {
gchar *both;
both = g_strdup_printf ("%s, %s", gsm, cdma);
g_autofree gchar *both = g_strdup_printf ("%s, %s", gsm, cdma);
panel_set_device_widget_details (device_mobile->builder, "provider", both);
g_free (both);
} else if (gsm != NULL) {
panel_set_device_widget_details (device_mobile->builder, "provider", gsm);
} else if (cdma != NULL) {
@ -538,11 +532,11 @@ device_mobile_get_registration_info_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
gchar *operator_code = NULL;
g_autofree gchar *operator_code = NULL;
g_autoptr(GError) error = NULL;
guint registration_status;
GVariant *result = NULL;
gchar *operator_name = NULL;
g_autofree gchar *operator_name = NULL;
NetDeviceMobile *device_mobile = (NetDeviceMobile *)user_data;
result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, &error);
@ -569,8 +563,6 @@ device_mobile_get_registration_info_cb (GObject *source_object,
"ControlCenter::OperatorNameGsm",
operator_name);
g_free (operator_name);
g_free (operator_code);
g_variant_unref (result);
}
@ -582,8 +574,8 @@ device_mobile_gsm_signal_cb (GDBusProxy *proxy,
gpointer user_data)
{
guint registration_status = 0;
gchar *operator_code = NULL;
gchar *operator_name = NULL;
g_autofree gchar *operator_code = NULL;
g_autofree gchar *operator_name = NULL;
NetDeviceMobile *device_mobile = (NetDeviceMobile *)user_data;
if (!g_str_equal (signal_name, "RegistrationInfo"))
@ -605,9 +597,6 @@ device_mobile_gsm_signal_cb (GDBusProxy *proxy,
device_mobile_save_operator_name (device_mobile,
"ControlCenter::OperatorNameGsm",
operator_name);
g_free (operator_code);
g_free (operator_name);
}
static void
@ -652,7 +641,7 @@ device_mobile_get_serving_system_cb (GObject *source_object,
g_autoptr(GError) error = NULL;
guint32 band_class;
gchar *band;
g_autofree gchar *band = NULL;
guint32 sid;
gchar *operator_name;
@ -676,7 +665,6 @@ device_mobile_get_serving_system_cb (GObject *source_object,
"ControlCenter::OperatorNameCdma",
operator_name);
g_free (band);
g_variant_unref (result);
}

View file

@ -346,9 +346,9 @@ static void
nm_device_wifi_refresh_hotspot (NetDeviceWifi *device_wifi)
{
GBytes *ssid;
gchar *hotspot_secret = NULL;
gchar *hotspot_security = NULL;
gchar *hotspot_ssid = NULL;
g_autofree gchar *hotspot_secret = NULL;
g_autofree gchar *hotspot_security = NULL;
g_autofree gchar *hotspot_ssid = NULL;
NMDevice *nm_device;
/* refresh hotspot ui */
@ -376,16 +376,12 @@ nm_device_wifi_refresh_hotspot (NetDeviceWifi *device_wifi)
panel_set_device_widget_details (device_wifi->builder,
"hotspot_connected",
NULL);
g_free (hotspot_secret);
g_free (hotspot_security);
g_free (hotspot_ssid);
}
static void
update_last_used (NetDeviceWifi *device_wifi, NMConnection *connection)
{
gchar *last_used = NULL;
g_autofree gchar *last_used = NULL;
GDateTime *now = NULL;
GDateTime *then = NULL;
gint days;
@ -421,7 +417,6 @@ out:
g_date_time_unref (now);
if (then != NULL)
g_date_time_unref (then);
g_free (last_used);
}
static void
@ -488,8 +483,8 @@ static void
nm_device_wifi_refresh_ui (NetDeviceWifi *device_wifi)
{
const gchar *str;
gchar *speed_text = NULL;
gchar *security_text = NULL;
g_autofree gchar *speed_text = NULL;
g_autofree gchar *security_text = NULL;
gint strength = 0;
guint speed = 0;
NMAccessPoint *active_ap;
@ -541,7 +536,6 @@ nm_device_wifi_refresh_ui (NetDeviceWifi *device_wifi)
panel_set_device_widget_details (device_wifi->builder,
"speed",
speed_text);
g_free (speed_text);
/* device MAC */
str = nm_device_wifi_get_hw_address (NM_DEVICE_WIFI (nm_device));
@ -554,7 +548,6 @@ nm_device_wifi_refresh_ui (NetDeviceWifi *device_wifi)
panel_set_device_widget_details (device_wifi->builder,
"security",
security_text);
g_free (security_text);
/* signal strength */
if (ap != NULL)
@ -828,11 +821,11 @@ static GBytes *
generate_ssid_for_hotspot (NetDeviceWifi *device_wifi)
{
GBytes *ssid_bytes;
gchar *hostname, *ssid;
g_autofree gchar *hostname = NULL;
gchar *ssid;
hostname = get_hostname ();
ssid = pretty_hostname_to_ssid (hostname);
g_free (hostname);
ssid_bytes = g_bytes_new_with_free_func (ssid,
strlen (ssid),
@ -1170,7 +1163,7 @@ start_hotspot (GtkButton *button, NetDeviceWifi *device_wifi)
{
NMDevice *device;
const GPtrArray *connections;
gchar *active_ssid;
g_autofree gchar *active_ssid = NULL;
NMClient *client;
GtkWidget *dialog;
GtkWidget *window;
@ -1178,8 +1171,6 @@ start_hotspot (GtkButton *button, NetDeviceWifi *device_wifi)
GtkWidget *label;
GString *str;
active_ssid = NULL;
client = net_object_get_client (NET_OBJECT (device_wifi));
device = net_device_get_nm_device (NET_DEVICE (device_wifi));
connections = nm_client_get_active_connections (client);
@ -1256,7 +1247,6 @@ start_hotspot (GtkButton *button, NetDeviceWifi *device_wifi)
G_CALLBACK (start_hotspot_response_cb), device_wifi);
gtk_window_present (GTK_WINDOW (dialog));
g_free (active_ssid);
g_string_free (str, TRUE);
}
@ -1424,7 +1414,7 @@ static void
device_wifi_edit (NetObject *object)
{
const gchar *uuid;
gchar *cmdline;
g_autofree gchar *cmdline = NULL;
g_autoptr(GError) error = NULL;
NetDeviceWifi *device = NET_DEVICE_WIFI (object);
NMClient *client;
@ -1441,7 +1431,6 @@ device_wifi_edit (NetObject *object)
g_debug ("Launching '%s'\n", cmdline);
if (!g_spawn_command_line_async (cmdline, &error))
g_warning ("Failed to launch nm-connection-editor: %s", error->message);
g_free (cmdline);
}
static void

View file

@ -102,21 +102,18 @@ compare_mac_device_with_mac_connection (NMDevice *device,
NMConnection *connection)
{
const gchar *mac_dev = NULL;
gchar *mac_conn = NULL;
g_autofree gchar *mac_conn = NULL;
mac_dev = get_mac_address_of_device (device);
if (mac_dev != NULL) {
mac_conn = get_mac_address_of_connection (connection);
if (mac_conn) {
/* compare both MACs */
if (g_strcmp0 (mac_dev, mac_conn) == 0) {
g_free (mac_conn);
return TRUE;
}
g_free (mac_conn);
}
}
if (mac_dev == NULL)
return FALSE;
mac_conn = get_mac_address_of_connection (connection);
if (mac_conn == NULL)
return FALSE;
/* compare both MACs */
return g_strcmp0 (mac_dev, mac_conn) == 0;
}
static NMConnection *
@ -190,7 +187,7 @@ static void
net_device_edit (NetObject *object)
{
const gchar *uuid;
gchar *cmdline;
g_autofree gchar *cmdline = NULL;
g_autoptr(GError) error = NULL;
NetDevice *device = NET_DEVICE (object);
NMConnection *connection;
@ -201,7 +198,6 @@ net_device_edit (NetObject *object)
g_debug ("Launching '%s'\n", cmdline);
if (!g_spawn_command_line_async (cmdline, &error))
g_warning ("Failed to launch nm-connection-editor: %s", error->message);
g_free (cmdline);
}
/**

View file

@ -76,7 +76,7 @@ static void
check_wpad_warning (NetProxy *proxy)
{
GtkWidget *widget;
gchar *autoconfig_url = NULL;
g_autofree gchar *autoconfig_url = NULL;
GString *string = NULL;
gboolean ret = FALSE;
guint mode;
@ -115,7 +115,6 @@ out:
gtk_label_set_markup (GTK_LABEL (widget), string->str);
gtk_widget_set_visible (widget, (string->len > 0));
g_free (autoconfig_url);
g_string_free (string, TRUE);
}
@ -243,7 +242,8 @@ get_ignore_hosts (GValue *value,
{
GVariantIter iter;
const gchar *s;
gchar **av, **p;
g_autofree gchar **av = NULL;
gchar **p;
gsize n;
n = g_variant_iter_init (&iter, variant);
@ -256,7 +256,6 @@ get_ignore_hosts (GValue *value,
}
g_value_take_string (value, g_strjoinv (", ", av));
g_free (av);
return TRUE;
}

View file

@ -154,7 +154,7 @@ nm_device_refresh_vpn_ui (NetVpn *vpn)
NMActiveConnection *a;
gint i;
NMVpnConnectionState state;
gchar *title;
g_autofree gchar *title = NULL;
NMClient *client;
/* update title */
@ -167,7 +167,6 @@ nm_device_refresh_vpn_ui (NetVpn *vpn)
title = g_strdup_printf (_("%s VPN"), nm_connection_get_id (vpn->connection));
net_object_set_title (NET_OBJECT (vpn), title);
gtk_label_set_label (GTK_LABEL (widget), title);
g_free (title);
if (vpn->active_connection) {
g_signal_handlers_disconnect_by_func (vpn->active_connection,
@ -281,7 +280,7 @@ vpn_proxy_edit (NetObject *object)
GtkWidget *button, *window;
NetConnectionEditor *editor;
NMClient *client;
gchar *title;
g_autofree gchar *title = NULL;
button = GTK_WIDGET (gtk_builder_get_object (vpn->builder,
"button_options"));
@ -294,7 +293,6 @@ vpn_proxy_edit (NetObject *object)
NULL, NULL, client);
title = g_strdup_printf (_("%s VPN"), nm_connection_get_id (vpn->connection));
net_connection_editor_set_title (editor, title);
g_free (title);
g_signal_connect (editor, "done", G_CALLBACK (editor_done), g_object_ref (vpn));
net_connection_editor_run (editor);

View file

@ -230,7 +230,7 @@ cc_network_panel_connect_to_8021x_network (GtkWidget *toplevel,
NMSetting8021x *s_8021x;
NM80211ApSecurityFlags wpa_flags, rsn_flags;
GtkWidget *dialog;
char *uuid;
g_autofree gchar *uuid = NULL;
NMAccessPoint *ap;
g_debug ("connect to 8021x wifi");
@ -258,7 +258,6 @@ cc_network_panel_connect_to_8021x_network (GtkWidget *toplevel,
s_con = (NMSettingConnection *) nm_setting_connection_new ();
uuid = nm_utils_uuid_generate ();
g_object_set (s_con, NM_SETTING_CONNECTION_UUID, uuid, NULL);
g_free (uuid);
nm_connection_add_setting (connection, NM_SETTING (s_con));
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
@ -315,7 +314,8 @@ cdma_mobile_wizard_done (NMAMobileWizard *wizard,
if (!canceled && method) {
NMSetting *setting;
char *uuid, *id;
g_autofree gchar *uuid = NULL;
g_autofree gchar *id = NULL;
if (method->devtype != NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO) {
g_warning ("Unexpected device type (not CDMA).");
@ -357,8 +357,6 @@ cdma_mobile_wizard_done (NMAMobileWizard *wizard,
NM_SETTING_CONNECTION_AUTOCONNECT, FALSE,
NM_SETTING_CONNECTION_UUID, uuid,
NULL);
g_free (uuid);
g_free (id);
nm_connection_add_setting (connection, setting);
}
@ -377,7 +375,8 @@ gsm_mobile_wizard_done (NMAMobileWizard *wizard,
if (!canceled && method) {
NMSetting *setting;
char *uuid, *id;
g_autofree gchar *uuid = NULL;
g_autofree gchar *id = NULL;
if (method->devtype != NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) {
g_warning ("Unexpected device type (not GSM).");
@ -420,8 +419,6 @@ gsm_mobile_wizard_done (NMAMobileWizard *wizard,
NM_SETTING_CONNECTION_AUTOCONNECT, FALSE,
NM_SETTING_CONNECTION_UUID, uuid,
NULL);
g_free (uuid);
g_free (id);
nm_connection_add_setting (connection, setting);
}

View file

@ -470,12 +470,11 @@ panel_set_device_status (GtkBuilder *builder,
const gchar *speed)
{
GtkLabel *label;
gchar *status;
g_autofree gchar *status = NULL;
label = GTK_LABEL (gtk_builder_get_object (builder, label_name));
status = device_status_to_localized_string (nm_device, speed);
gtk_label_set_label (label, status);
g_free (status);
}
void
@ -497,8 +496,8 @@ panel_set_device_widget_details (GtkBuilder *builder,
const gchar *widget_suffix,
const gchar *value)
{
gchar *heading_id;
gchar *label_id;
g_autofree gchar *heading_id = NULL;
g_autofree gchar *label_id = NULL;
GtkWidget *heading;
GtkWidget *widget;
@ -511,8 +510,6 @@ panel_set_device_widget_details (GtkBuilder *builder,
g_critical ("no widgets %s, %s found", heading_id, label_id);
return FALSE;
}
g_free (heading_id);
g_free (label_id);
if (value == NULL) {
gtk_widget_hide (heading);
@ -534,7 +531,7 @@ panel_set_device_widget_header (GtkBuilder *builder,
const gchar *widget_suffix,
const gchar *heading)
{
gchar *label_id = NULL;
g_autofree gchar *label_id = NULL;
GtkWidget *widget;
label_id = g_strdup_printf ("heading_%s", widget_suffix);
@ -544,7 +541,6 @@ panel_set_device_widget_header (GtkBuilder *builder,
return FALSE;
}
gtk_label_set_label (GTK_LABEL (widget), heading);
g_free (label_id);
return TRUE;
}

View file

@ -139,7 +139,7 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
GtkWidget *widget;
const char *text;
char *filename;
g_autofree gchar *filename = NULL;
EAPMethod *eap = NULL;
GtkTreeModel *model;
GtkTreeIter iter;
@ -166,7 +166,6 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
ca_cert_error = TRUE;
}
eap_method_ca_cert_ignore_set (parent, connection, filename, ca_cert_error);
g_free (filename);
widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_version_combo"));
peapver_active = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));

View file

@ -163,7 +163,8 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
NMSetting8021x *s_8021x;
NMSettingSecretFlags secret_flags;
GtkWidget *widget, *passwd_entry;
char *ca_filename, *pk_filename, *cc_filename;
g_autofree gchar *ca_filename = NULL;
g_autofree gchar *pk_filename = NULL;
const char *password = NULL;
gboolean ca_cert_error = FALSE;
@ -200,7 +201,6 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
if (!nm_setting_802_1x_set_private_key (s_8021x, pk_filename, password, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error))
g_warning ("Couldn't read private key '%s': %s", pk_filename, error ? error->message : "(unknown)");
}
g_free (pk_filename);
/* Save 802.1X password flags to the connection */
secret_flags = nma_utils_menu_to_secret_flags (passwd_entry);
@ -215,6 +215,8 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
/* TLS client certificate */
if (format != NM_SETTING_802_1X_CK_FORMAT_PKCS12) {
g_autofree gchar *cc_filename = NULL;
/* If the key is pkcs#12 nm_setting_802_1x_set_private_key() already
* set the client certificate for us.
*/
@ -233,7 +235,6 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
if (!nm_setting_802_1x_set_client_cert (s_8021x, cc_filename, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error))
g_warning ("Couldn't read client certificate '%s': %s", cc_filename, error ? error->message : "(unknown)");
}
g_free (cc_filename);
}
/* TLS CA certificate */
@ -256,7 +257,6 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
}
}
eap_method_ca_cert_ignore_set (parent, connection, ca_filename, ca_cert_error);
g_free (ca_filename);
}
static void
@ -311,12 +311,11 @@ static void
private_key_picker_file_set_cb (GtkWidget *chooser, gpointer user_data)
{
EAPMethod *parent = (EAPMethod *) user_data;
char *filename;
g_autofree gchar *filename = NULL;
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
if (filename)
private_key_picker_helper (parent, filename, TRUE);
g_free (filename);
}
static void reset_filter (GtkWidget *widget, GParamSpec *spec, gpointer user_data)

View file

@ -139,7 +139,7 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
GtkWidget *widget;
const char *text;
char *filename;
g_autofree gchar *filename = NULL;
EAPMethod *eap = NULL;
GtkTreeModel *model;
GtkTreeIter iter;
@ -171,7 +171,6 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
ca_cert_error = TRUE;
}
eap_method_ca_cert_ignore_set (parent, connection, filename, ca_cert_error);
g_free (filename);
widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_ttls_inner_auth_combo"));
model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));

View file

@ -227,7 +227,7 @@ eap_method_validate_filepicker (GtkBuilder *builder,
GError **error)
{
GtkWidget *widget;
char *filename;
g_autofree gchar *filename = NULL;
NMSetting8021x *setting;
gboolean success = TRUE;
@ -270,8 +270,6 @@ eap_method_validate_filepicker (GtkBuilder *builder,
g_object_unref (setting);
out:
g_free (filename);
if (!success && error && !*error)
g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("unspecified error validating eap-method file"));
@ -285,7 +283,8 @@ out:
static gboolean
file_has_extension (const char *filename, const char *extensions[])
{
char *p, *ext;
char *p;
g_autofree gchar *ext = NULL;
int i = 0;
gboolean found = FALSE;
@ -302,7 +301,6 @@ file_has_extension (const char *filename, const char *extensions[])
}
}
}
g_free (ext);
return found;
}
@ -486,7 +484,6 @@ eap_method_is_encrypted_private_key (const char *path)
gboolean
eap_method_ca_cert_required (GtkBuilder *builder, const char *id_ca_cert_not_required_checkbutton, const char *id_ca_cert_chooser)
{
char *filename;
GtkWidget *widget;
g_assert (builder && id_ca_cert_not_required_checkbutton && id_ca_cert_chooser);
@ -495,13 +492,14 @@ eap_method_ca_cert_required (GtkBuilder *builder, const char *id_ca_cert_not_req
g_assert (widget && GTK_IS_TOGGLE_BUTTON (widget));
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) {
g_autofree gchar *filename = NULL;
widget = GTK_WIDGET (gtk_builder_get_object (builder, id_ca_cert_chooser));
g_assert (widget && GTK_IS_FILE_CHOOSER (widget));
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
if (!filename)
return TRUE;
g_free (filename);
}
return FALSE;
}
@ -510,7 +508,8 @@ eap_method_ca_cert_required (GtkBuilder *builder, const char *id_ca_cert_not_req
void
eap_method_ca_cert_not_required_toggled (GtkBuilder *builder, const char *id_ca_cert_not_required_checkbutton, const char *id_ca_cert_chooser)
{
char *filename, *filename_old;
g_autofree gchar *filename = NULL;
g_autofree gchar *filename_old = NULL;
gboolean is_not_required;
GtkWidget *widget;
@ -527,20 +526,17 @@ eap_method_ca_cert_not_required_toggled (GtkBuilder *builder, const char *id_ca_
filename_old = g_object_steal_data (G_OBJECT (widget), "filename-old");
if (is_not_required) {
g_free (filename_old);
filename_old = filename;
filename = NULL;
filename_old = g_steal_pointer (&filename);
} else {
g_free (filename);
filename = filename_old;
filename_old = NULL;
filename = g_steal_pointer (&filename_old);
}
gtk_widget_set_sensitive (widget, !is_not_required);
if (filename)
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (widget), filename);
else
gtk_file_chooser_unselect_all (GTK_FILE_CHOOSER (widget));
g_free (filename);
g_object_set_data_full (G_OBJECT (widget), "filename-old", filename_old, g_free);
g_object_set_data_full (G_OBJECT (widget), "filename-old", g_steal_pointer (&filename_old), g_free);
}
/* Used as both GSettings keys and GObject data tags */
@ -604,7 +600,7 @@ static GSettings *
_get_ca_ignore_settings (NMConnection *connection)
{
GSettings *settings;
char *path = NULL;
g_autofree gchar *path = NULL;
const char *uuid;
g_return_val_if_fail (connection, NULL);
@ -614,7 +610,6 @@ _get_ca_ignore_settings (NMConnection *connection)
path = g_strdup_printf ("/org/gnome/nm-applet/eap/%s/", uuid);
settings = g_settings_new_with_path ("org.gnome.nm-applet.eap", path);
g_free (path);
return settings;
}

View file

@ -42,7 +42,7 @@ utils_filter_editable_on_insert_text (GtkEditable *editable,
gpointer block_func)
{
int i, count = 0;
gchar *result = g_new (gchar, length+1);
g_autofree gchar *result = g_new (gchar, length+1);
for (i = 0; i < length; i++) {
if (validate_character (text[i]))
@ -65,8 +65,6 @@ utils_filter_editable_on_insert_text (GtkEditable *editable,
}
g_signal_stop_emission_by_name (G_OBJECT (editable), "insert-text");
g_free (result);
return count > 0;
}