network: Use g_autoptr for GError handling

This commit is contained in:
Robert Ancell 2019-09-12 10:54:37 +12:00
parent 072d5daf5c
commit 01190db349
18 changed files with 73 additions and 135 deletions

View file

@ -860,7 +860,7 @@ cc_network_panel_class_init (CcNetworkPanelClass *klass)
static void static void
cc_network_panel_init (CcNetworkPanel *panel) cc_network_panel_init (CcNetworkPanel *panel)
{ {
GError *error = NULL; g_autoptr(GError) error = NULL;
GtkWidget *toplevel; GtkWidget *toplevel;
GDBusConnection *system_bus; GDBusConnection *system_bus;
const GPtrArray *connections; const GPtrArray *connections;
@ -901,17 +901,14 @@ cc_network_panel_init (CcNetworkPanel *panel)
if (system_bus == NULL) { if (system_bus == NULL) {
g_warning ("Error connecting to system D-Bus: %s", g_warning ("Error connecting to system D-Bus: %s",
error->message); error->message);
g_clear_error (&error);
} else { } else {
panel->modem_manager = mm_manager_new_sync (system_bus, panel->modem_manager = mm_manager_new_sync (system_bus,
G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE, G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE,
NULL, NULL,
&error); &error);
if (panel->modem_manager == NULL) { if (panel->modem_manager == NULL)
g_warning ("Error connecting to ModemManager: %s", g_warning ("Error connecting to ModemManager: %s",
error->message); error->message);
g_clear_error (&error);
}
g_object_unref (system_bus); g_object_unref (system_bus);
} }

View file

@ -500,9 +500,8 @@ rfkill_proxy_acquired_cb (GObject *source_object,
{ {
CcWifiPanel *self; CcWifiPanel *self;
GDBusProxy *proxy; GDBusProxy *proxy;
GError *error; g_autoptr(GError) error = NULL;
error = NULL;
proxy = cc_object_storage_create_dbus_proxy_finish (res, &error); proxy = cc_object_storage_create_dbus_proxy_finish (res, &error);
if (error) if (error)
@ -510,7 +509,6 @@ rfkill_proxy_acquired_cb (GObject *source_object,
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
g_printerr ("Error creating rfkill proxy: %s\n", error->message); g_printerr ("Error creating rfkill proxy: %s\n", error->message);
g_error_free (error);
return; return;
} }

View file

@ -222,7 +222,7 @@ ce_page_new (GType type,
const gchar *title) const gchar *title)
{ {
CEPage *page; CEPage *page;
GError *error = NULL; g_autoptr(GError) error = NULL;
page = CE_PAGE (g_object_new (type, page = CE_PAGE (g_object_new (type,
"connection", connection, "connection", connection,
@ -233,7 +233,6 @@ ce_page_new (GType type,
if (ui_resource) { if (ui_resource) {
if (!gtk_builder_add_from_resource (page->builder, ui_resource, &error)) { if (!gtk_builder_add_from_resource (page->builder, ui_resource, &error)) {
g_warning ("Couldn't load builder file: %s", error->message); g_warning ("Couldn't load builder file: %s", error->message);
g_error_free (error);
g_object_unref (page); g_object_unref (page);
return NULL; return NULL;
} }
@ -265,7 +264,7 @@ ce_page_complete_init (CEPage *page,
GVariant *secrets, GVariant *secrets,
GError *error) GError *error)
{ {
GError *update_error = NULL; g_autoptr(GError) update_error = NULL;
GVariant *setting_dict; GVariant *setting_dict;
gboolean ignore_error = FALSE; gboolean ignore_error = FALSE;
@ -304,7 +303,6 @@ ce_page_complete_init (CEPage *page,
secrets, secrets,
&update_error)) { &update_error)) {
g_warning ("Couldn't update secrets: %s", update_error->message); g_warning ("Couldn't update secrets: %s", update_error->message);
g_error_free (update_error);
/* Success */ /* Success */
emit_initialized (page, NULL); emit_initialized (page, NULL);
return; return;

View file

@ -94,14 +94,13 @@ updated_connection_cb (GObject *source_object,
gpointer user_data) gpointer user_data)
{ {
NetConnectionEditor *editor; NetConnectionEditor *editor;
GError *error = NULL; g_autoptr(GError) error = NULL;
gboolean success = TRUE; gboolean success = TRUE;
if (!nm_remote_connection_commit_changes_finish (NM_REMOTE_CONNECTION (source_object), if (!nm_remote_connection_commit_changes_finish (NM_REMOTE_CONNECTION (source_object),
res, &error)) { res, &error)) {
g_warning ("Failed to commit changes: %s", error->message); g_warning ("Failed to commit changes: %s", error->message);
success = FALSE; success = FALSE;
g_error_free (error);
//return; FIXME return if cancelled //return; FIXME return if cancelled
} }
@ -117,13 +116,12 @@ added_connection_cb (GObject *source_object,
gpointer user_data) gpointer user_data)
{ {
NetConnectionEditor *editor; NetConnectionEditor *editor;
GError *error = NULL; g_autoptr(GError) error = NULL;
gboolean success = TRUE; gboolean success = TRUE;
if (!nm_client_add_connection_finish (NM_CLIENT (source_object), res, &error)) { if (!nm_client_add_connection_finish (NM_CLIENT (source_object), res, &error)) {
g_warning ("Failed to add connection: %s", error->message); g_warning ("Failed to add connection: %s", error->message);
success = FALSE; success = FALSE;
g_error_free (error);
/* Leave the editor open */ /* Leave the editor open */
// return; FIXME return if cancelled // return; FIXME return if cancelled
} }
@ -244,7 +242,7 @@ static void
net_connection_editor_do_fallback (NetConnectionEditor *editor, const gchar *type) net_connection_editor_do_fallback (NetConnectionEditor *editor, const gchar *type)
{ {
gchar *cmdline; gchar *cmdline;
GError *error = NULL; g_autoptr(GError) error = NULL;
if (editor->is_new_connection) { if (editor->is_new_connection) {
cmdline = g_strdup_printf ("nm-connection-editor --type='%s' --create", type); cmdline = g_strdup_printf ("nm-connection-editor --type='%s' --create", type);
@ -256,12 +254,10 @@ net_connection_editor_do_fallback (NetConnectionEditor *editor, const gchar *typ
g_spawn_command_line_async (cmdline, &error); g_spawn_command_line_async (cmdline, &error);
g_free (cmdline); g_free (cmdline);
if (error) { if (error)
net_connection_editor_error_dialog (editor, net_connection_editor_error_dialog (editor,
_("Unable to open connection editor"), _("Unable to open connection editor"),
error->message); error->message);
g_error_free (error);
}
g_signal_emit (editor, signals[DONE], 0, FALSE); g_signal_emit (editor, signals[DONE], 0, FALSE);
} }
@ -338,13 +334,12 @@ validate (NetConnectionEditor *editor)
valid = TRUE; valid = TRUE;
for (l = editor->pages; l; l = l->next) { for (l = editor->pages; l; l = l->next) {
GError *error = NULL; g_autoptr(GError) error = NULL;
if (!ce_page_validate (CE_PAGE (l->data), editor->connection, &error)) { if (!ce_page_validate (CE_PAGE (l->data), editor->connection, &error)) {
valid = FALSE; valid = FALSE;
if (error) { if (error) {
g_debug ("Invalid setting %s: %s", ce_page_get_title (CE_PAGE (l->data)), error->message); g_debug ("Invalid setting %s: %s", ce_page_get_title (CE_PAGE (l->data)), error->message);
g_error_free (error);
} else { } else {
g_debug ("Invalid setting %s", ce_page_get_title (CE_PAGE (l->data))); g_debug ("Invalid setting %s", ce_page_get_title (CE_PAGE (l->data)));
} }
@ -830,14 +825,13 @@ forgotten_cb (GObject *source_object,
{ {
NMRemoteConnection *connection = NM_REMOTE_CONNECTION (source_object); NMRemoteConnection *connection = NM_REMOTE_CONNECTION (source_object);
NetConnectionEditor *editor = user_data; NetConnectionEditor *editor = user_data;
GError *error = NULL; g_autoptr(GError) error = NULL;
if (!nm_remote_connection_delete_finish (connection, res, &error)) { if (!nm_remote_connection_delete_finish (connection, res, &error)) {
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
g_warning ("Failed to delete connection %s: %s", g_warning ("Failed to delete connection %s: %s",
nm_connection_get_id (NM_CONNECTION (connection)), nm_connection_get_id (NM_CONNECTION (connection)),
error->message); error->message);
g_error_free (error);
return; return;
} }

View file

@ -65,7 +65,7 @@ vpn_get_plugins (void)
plugins = NULL; plugins = NULL;
while (p) { while (p) {
NMVpnPluginInfo *plugin_info = NM_VPN_PLUGIN_INFO (p->data); NMVpnPluginInfo *plugin_info = NM_VPN_PLUGIN_INFO (p->data);
GError *error = NULL; g_autoptr(GError) error = NULL;
/* load the editor plugin, and preserve only those NMVpnPluginInfo that can /* load the editor plugin, and preserve only those NMVpnPluginInfo that can
* successfully load the plugin. */ * successfully load the plugin. */
@ -88,7 +88,6 @@ vpn_get_plugins (void)
nm_vpn_plugin_info_get_filename (plugin_info), nm_vpn_plugin_info_get_filename (plugin_info),
error->message); error->message);
} }
g_clear_error (&error);
g_object_unref (plugin_info); g_object_unref (plugin_info);
} }
p = g_slist_delete_link (p, p); p = g_slist_delete_link (p, p);
@ -110,7 +109,7 @@ import_vpn_from_file_cb (GtkWidget *dialog, gint response, gpointer user_data)
char *filename = NULL; char *filename = NULL;
ActionInfo *info = (ActionInfo *) user_data; ActionInfo *info = (ActionInfo *) user_data;
NMConnection *connection = NULL; NMConnection *connection = NULL;
GError *error = NULL; g_autoptr(GError) error = NULL;
GSList *iter; GSList *iter;
if (response != GTK_RESPONSE_ACCEPT) if (response != GTK_RESPONSE_ACCEPT)
@ -147,7 +146,6 @@ import_vpn_from_file_cb (GtkWidget *dialog, gint response, gpointer user_data)
g_signal_connect (err_dialog, "response", 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)); gtk_dialog_run (GTK_DIALOG (err_dialog));
} }
g_clear_error (&error);
g_free (filename); g_free (filename);
out: out:
@ -200,7 +198,7 @@ export_vpn_to_file_cb (GtkWidget *dialog, gint response, gpointer user_data)
{ {
NMConnection *connection = NM_CONNECTION (user_data); NMConnection *connection = NM_CONNECTION (user_data);
char *filename = NULL; char *filename = NULL;
GError *error = NULL; g_autoptr(GError) error = NULL;
NMVpnEditorPlugin *plugin; NMVpnEditorPlugin *plugin;
NMSettingConnection *s_con = NULL; NMSettingConnection *s_con = NULL;
NMSettingVpn *s_vpn = NULL; NMSettingVpn *s_vpn = NULL;
@ -279,8 +277,6 @@ done:
} }
out: out:
if (error)
g_error_free (error);
g_object_unref (connection); g_object_unref (connection);
gtk_widget_hide (dialog); gtk_widget_hide (dialog);

View file

@ -609,7 +609,7 @@ net_device_ethernet_class_init (NetDeviceEthernetClass *klass)
static void static void
net_device_ethernet_init (NetDeviceEthernet *device) net_device_ethernet_init (NetDeviceEthernet *device)
{ {
GError *error = NULL; g_autoptr(GError) error = NULL;
device->builder = gtk_builder_new (); device->builder = gtk_builder_new ();
gtk_builder_add_from_resource (device->builder, gtk_builder_add_from_resource (device->builder,
@ -617,7 +617,6 @@ net_device_ethernet_init (NetDeviceEthernet *device)
&error); &error);
if (error != NULL) { if (error != NULL) {
g_warning ("Could not load interface file: %s", error->message); g_warning ("Could not load interface file: %s", error->message);
g_error_free (error);
return; return;
} }

View file

@ -93,12 +93,11 @@ connection_activate_cb (GObject *source_object,
GAsyncResult *res, GAsyncResult *res,
gpointer user_data) gpointer user_data)
{ {
GError *error = NULL; g_autoptr(GError) error = NULL;
if (!nm_client_activate_connection_finish (NM_CLIENT (source_object), res, &error)) { if (!nm_client_activate_connection_finish (NM_CLIENT (source_object), res, &error)) {
/* failed to activate */ /* failed to activate */
nm_device_mobile_refresh_ui (user_data); nm_device_mobile_refresh_ui (user_data);
g_error_free (error);
} }
} }
@ -275,14 +274,13 @@ device_mobile_find_provider (NetDeviceMobile *device_mobile,
GString *name = NULL; GString *name = NULL;
if (device_mobile->mpd == NULL) { if (device_mobile->mpd == NULL) {
GError *error = NULL; g_autoptr(GError) error = NULL;
/* Use defaults */ /* Use defaults */
device_mobile->mpd = nma_mobile_providers_database_new_sync (NULL, NULL, NULL, &error); device_mobile->mpd = nma_mobile_providers_database_new_sync (NULL, NULL, NULL, &error);
if (device_mobile->mpd == NULL) { if (device_mobile->mpd == NULL) {
g_debug ("Couldn't load mobile providers database: %s", g_debug ("Couldn't load mobile providers database: %s",
error ? error->message : ""); error ? error->message : "");
g_clear_error (&error);
return NULL; return NULL;
} }
} }
@ -487,7 +485,7 @@ device_mobile_device_got_modem_manager_cb (GObject *source_object,
GAsyncResult *res, GAsyncResult *res,
gpointer user_data) gpointer user_data)
{ {
GError *error = NULL; g_autoptr(GError) error = NULL;
GVariant *result = NULL; GVariant *result = NULL;
GDBusProxy *proxy; GDBusProxy *proxy;
NetDeviceMobile *device_mobile = (NetDeviceMobile *)user_data; NetDeviceMobile *device_mobile = (NetDeviceMobile *)user_data;
@ -496,7 +494,6 @@ device_mobile_device_got_modem_manager_cb (GObject *source_object,
if (!proxy) { if (!proxy) {
g_warning ("Error creating ModemManager proxy: %s", g_warning ("Error creating ModemManager proxy: %s",
error->message); error->message);
g_error_free (error);
return; return;
} }
@ -542,7 +539,7 @@ device_mobile_get_registration_info_cb (GObject *source_object,
gpointer user_data) gpointer user_data)
{ {
gchar *operator_code = NULL; gchar *operator_code = NULL;
GError *error = NULL; g_autoptr(GError) error = NULL;
guint registration_status; guint registration_status;
GVariant *result = NULL; GVariant *result = NULL;
gchar *operator_name = NULL; gchar *operator_name = NULL;
@ -552,7 +549,6 @@ device_mobile_get_registration_info_cb (GObject *source_object,
if (result == NULL) { if (result == NULL) {
g_warning ("Error getting registration info: %s\n", g_warning ("Error getting registration info: %s\n",
error->message); error->message);
g_error_free (error);
return; return;
} }
@ -619,14 +615,13 @@ device_mobile_device_got_modem_manager_gsm_cb (GObject *source_object,
GAsyncResult *res, GAsyncResult *res,
gpointer user_data) gpointer user_data)
{ {
GError *error = NULL; g_autoptr(GError) error = NULL;
NetDeviceMobile *device_mobile = (NetDeviceMobile *)user_data; NetDeviceMobile *device_mobile = (NetDeviceMobile *)user_data;
device_mobile->gsm_proxy = g_dbus_proxy_new_for_bus_finish (res, &error); device_mobile->gsm_proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
if (device_mobile->gsm_proxy == NULL) { if (device_mobile->gsm_proxy == NULL) {
g_warning ("Error creating ModemManager GSM proxy: %s\n", g_warning ("Error creating ModemManager GSM proxy: %s\n",
error->message); error->message);
g_error_free (error);
return; return;
} }
@ -654,7 +649,7 @@ device_mobile_get_serving_system_cb (GObject *source_object,
{ {
NetDeviceMobile *device_mobile = (NetDeviceMobile *)user_data; NetDeviceMobile *device_mobile = (NetDeviceMobile *)user_data;
GVariant *result = NULL; GVariant *result = NULL;
GError *error = NULL; g_autoptr(GError) error = NULL;
guint32 band_class; guint32 band_class;
gchar *band; gchar *band;
@ -665,7 +660,6 @@ device_mobile_get_serving_system_cb (GObject *source_object,
if (result == NULL) { if (result == NULL) {
g_warning ("Error getting serving system: %s\n", g_warning ("Error getting serving system: %s\n",
error->message); error->message);
g_error_free (error);
return; return;
} }
@ -691,14 +685,13 @@ device_mobile_device_got_modem_manager_cdma_cb (GObject *source_object,
GAsyncResult *res, GAsyncResult *res,
gpointer user_data) gpointer user_data)
{ {
GError *error = NULL; g_autoptr(GError) error = NULL;
NetDeviceMobile *device_mobile = (NetDeviceMobile *)user_data; NetDeviceMobile *device_mobile = (NetDeviceMobile *)user_data;
device_mobile->cdma_proxy = g_dbus_proxy_new_for_bus_finish (res, &error); device_mobile->cdma_proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
if (device_mobile->cdma_proxy == NULL) { if (device_mobile->cdma_proxy == NULL) {
g_warning ("Error creating ModemManager CDMA proxy: %s\n", g_warning ("Error creating ModemManager CDMA proxy: %s\n",
error->message); error->message);
g_error_free (error);
return; return;
} }
@ -891,7 +884,7 @@ net_device_mobile_class_init (NetDeviceMobileClass *klass)
static void static void
net_device_mobile_init (NetDeviceMobile *device_mobile) net_device_mobile_init (NetDeviceMobile *device_mobile)
{ {
GError *error = NULL; g_autoptr(GError) error = NULL;
GtkWidget *widget; GtkWidget *widget;
GtkCellRenderer *renderer; GtkCellRenderer *renderer;
GtkComboBox *combobox; GtkComboBox *combobox;
@ -902,7 +895,6 @@ net_device_mobile_init (NetDeviceMobile *device_mobile)
&error); &error);
if (error != NULL) { if (error != NULL) {
g_warning ("Could not load interface file: %s", error->message); g_warning ("Could not load interface file: %s", error->message);
g_error_free (error);
return; return;
} }

View file

@ -220,7 +220,7 @@ static void
net_device_simple_init (NetDeviceSimple *device_simple) net_device_simple_init (NetDeviceSimple *device_simple)
{ {
NetDeviceSimplePrivate *priv = net_device_simple_get_instance_private (device_simple); NetDeviceSimplePrivate *priv = net_device_simple_get_instance_private (device_simple);
GError *error = NULL; g_autoptr(GError) error = NULL;
GtkWidget *widget; GtkWidget *widget;
priv->builder = gtk_builder_new (); priv->builder = gtk_builder_new ();
@ -229,7 +229,6 @@ net_device_simple_init (NetDeviceSimple *device_simple)
&error); &error);
if (error != NULL) { if (error != NULL) {
g_warning ("Could not load interface file: %s", error->message); g_warning ("Could not load interface file: %s", error->message);
g_error_free (error);
return; return;
} }

View file

@ -266,13 +266,12 @@ get_secrets_cb (GObject *source_object,
{ {
NetDeviceWifi *device_wifi = data; NetDeviceWifi *device_wifi = data;
GVariant *secrets; GVariant *secrets;
GError *error = NULL; g_autoptr(GError) error = NULL;
secrets = nm_remote_connection_get_secrets_finish (NM_REMOTE_CONNECTION (source_object), res, &error); secrets = nm_remote_connection_get_secrets_finish (NM_REMOTE_CONNECTION (source_object), res, &error);
if (!secrets) { if (!secrets) {
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
g_warning ("Could not get secrets: %s", error->message); g_warning ("Could not get secrets: %s", error->message);
g_error_free (error);
return; return;
} }
@ -646,7 +645,7 @@ connection_add_activate_cb (GObject *source_object,
gpointer user_data) gpointer user_data)
{ {
NMActiveConnection *conn; NMActiveConnection *conn;
GError *error = NULL; g_autoptr(GError) error = NULL;
conn = nm_client_add_and_activate_connection_finish (NM_CLIENT (source_object), res, &error); conn = nm_client_add_and_activate_connection_finish (NM_CLIENT (source_object), res, &error);
if (!conn) { if (!conn) {
@ -657,7 +656,6 @@ connection_add_activate_cb (GObject *source_object,
error->code, error->code,
error->message); error->message);
} }
g_error_free (error);
return; return;
} }
} }
@ -667,7 +665,7 @@ connection_activate_cb (GObject *source_object,
GAsyncResult *res, GAsyncResult *res,
gpointer user_data) gpointer user_data)
{ {
GError *error = NULL; g_autoptr(GError) error = NULL;
if (!nm_client_activate_connection_finish (NM_CLIENT (source_object), res, &error)) { if (!nm_client_activate_connection_finish (NM_CLIENT (source_object), res, &error)) {
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
@ -677,7 +675,6 @@ connection_activate_cb (GObject *source_object,
error->code, error->code,
error->message); error->message);
} }
g_error_free (error);
return; return;
} }
} }
@ -791,14 +788,11 @@ get_hostname (void)
GVariant *res; GVariant *res;
GVariant *inner; GVariant *inner;
gchar *str; gchar *str;
GError *error; g_autoptr(GError) error = NULL;
error = NULL;
bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error); bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
if (bus == NULL) { if (bus == NULL) {
g_warning ("Failed to get system bus connection: %s", error->message); g_warning ("Failed to get system bus connection: %s", error->message);
g_error_free (error);
return NULL; return NULL;
} }
res = g_dbus_connection_call_sync (bus, res = g_dbus_connection_call_sync (bus,
@ -816,10 +810,8 @@ get_hostname (void)
&error); &error);
g_object_unref (bus); g_object_unref (bus);
if (res == NULL) { if (res == NULL)
g_warning ("Getting pretty hostname failed: %s", error->message); g_warning ("Getting pretty hostname failed: %s", error->message);
g_error_free (error);
}
str = NULL; str = NULL;
@ -946,13 +938,12 @@ activate_cb (GObject *source_object,
GAsyncResult *res, GAsyncResult *res,
gpointer user_data) gpointer user_data)
{ {
GError *error = NULL; g_autoptr(GError) error = NULL;
if (nm_client_activate_connection_finish (NM_CLIENT (source_object), res, &error) == NULL) { if (nm_client_activate_connection_finish (NM_CLIENT (source_object), res, &error) == NULL) {
g_warning ("Failed to add new connection: (%d) %s", g_warning ("Failed to add new connection: (%d) %s",
error->code, error->code,
error->message); error->message);
g_error_free (error);
return; return;
} }
@ -966,7 +957,7 @@ activate_new_cb (GObject *source_object,
gpointer user_data) gpointer user_data)
{ {
NMActiveConnection *conn; NMActiveConnection *conn;
GError *error = NULL; g_autoptr(GError) error = NULL;
conn = nm_client_add_and_activate_connection_finish (NM_CLIENT (source_object), conn = nm_client_add_and_activate_connection_finish (NM_CLIENT (source_object),
res, &error); res, &error);
@ -974,7 +965,6 @@ activate_new_cb (GObject *source_object,
g_warning ("Failed to add new connection: (%d) %s", g_warning ("Failed to add new connection: (%d) %s",
error->code, error->code,
error->message); error->message);
g_error_free (error);
return; return;
} }
@ -1006,7 +996,7 @@ overwrite_ssid_cb (GObject *source_object,
GAsyncResult *res, GAsyncResult *res,
gpointer user_data) gpointer user_data)
{ {
GError *error = NULL; g_autoptr(GError) error = NULL;
NMClient *client; NMClient *client;
NMRemoteConnection *connection; NMRemoteConnection *connection;
NMDevice *device; NMDevice *device;
@ -1020,7 +1010,6 @@ overwrite_ssid_cb (GObject *source_object,
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
g_warning ("Failed to save hotspot's settings to disk: %s", g_warning ("Failed to save hotspot's settings to disk: %s",
error->message); error->message);
g_error_free (error);
return; return;
} }
@ -1436,7 +1425,7 @@ device_wifi_edit (NetObject *object)
{ {
const gchar *uuid; const gchar *uuid;
gchar *cmdline; gchar *cmdline;
GError *error = NULL; g_autoptr(GError) error = NULL;
NetDeviceWifi *device = NET_DEVICE_WIFI (object); NetDeviceWifi *device = NET_DEVICE_WIFI (object);
NMClient *client; NMClient *client;
NMRemoteConnection *connection; NMRemoteConnection *connection;
@ -1450,10 +1439,8 @@ device_wifi_edit (NetObject *object)
uuid = nm_connection_get_uuid (NM_CONNECTION (connection)); uuid = nm_connection_get_uuid (NM_CONNECTION (connection));
cmdline = g_strdup_printf ("nm-connection-editor --edit %s", uuid); cmdline = g_strdup_printf ("nm-connection-editor --edit %s", uuid);
g_debug ("Launching '%s'\n", cmdline); g_debug ("Launching '%s'\n", cmdline);
if (!g_spawn_command_line_async (cmdline, &error)) { if (!g_spawn_command_line_async (cmdline, &error))
g_warning ("Failed to launch nm-connection-editor: %s", error->message); g_warning ("Failed to launch nm-connection-editor: %s", error->message);
g_error_free (error);
}
g_free (cmdline); g_free (cmdline);
} }
@ -1503,7 +1490,7 @@ really_forgotten (GObject *source_object,
gpointer user_data) gpointer user_data)
{ {
CcWifiConnectionList *list = user_data; CcWifiConnectionList *list = user_data;
GError *error = NULL; g_autoptr(GError) error = NULL;
cc_wifi_connection_list_thaw (list); cc_wifi_connection_list_thaw (list);
g_object_unref (list); g_object_unref (list);
@ -1512,7 +1499,6 @@ really_forgotten (GObject *source_object,
g_warning ("failed to delete connection %s: %s", g_warning ("failed to delete connection %s: %s",
nm_object_get_path (NM_OBJECT (source_object)), nm_object_get_path (NM_OBJECT (source_object)),
error->message); error->message);
g_error_free (error);
return; return;
} }
} }
@ -1853,7 +1839,7 @@ ap_activated (GtkListBox *list, GtkListBoxRow *row, NetDeviceWifi *device_wifi)
static void static void
net_device_wifi_init (NetDeviceWifi *device_wifi) net_device_wifi_init (NetDeviceWifi *device_wifi)
{ {
GError *error = NULL; g_autoptr(GError) error = NULL;
GtkWidget *widget; GtkWidget *widget;
device_wifi->builder = gtk_builder_new (); device_wifi->builder = gtk_builder_new ();
@ -1862,7 +1848,6 @@ net_device_wifi_init (NetDeviceWifi *device_wifi)
&error); &error);
if (error != NULL) { if (error != NULL) {
g_warning ("Could not load interface file: %s", error->message); g_warning ("Could not load interface file: %s", error->message);
g_error_free (error);
return; return;
} }

View file

@ -191,7 +191,7 @@ net_device_edit (NetObject *object)
{ {
const gchar *uuid; const gchar *uuid;
gchar *cmdline; gchar *cmdline;
GError *error = NULL; g_autoptr(GError) error = NULL;
NetDevice *device = NET_DEVICE (object); NetDevice *device = NET_DEVICE (object);
NMConnection *connection; NMConnection *connection;
@ -199,10 +199,8 @@ net_device_edit (NetObject *object)
uuid = nm_connection_get_uuid (connection); uuid = nm_connection_get_uuid (connection);
cmdline = g_strdup_printf ("nm-connection-editor --edit %s", uuid); cmdline = g_strdup_printf ("nm-connection-editor --edit %s", uuid);
g_debug ("Launching '%s'\n", cmdline); g_debug ("Launching '%s'\n", cmdline);
if (!g_spawn_command_line_async (cmdline, &error)) { if (!g_spawn_command_line_async (cmdline, &error))
g_warning ("Failed to launch nm-connection-editor: %s", error->message); g_warning ("Failed to launch nm-connection-editor: %s", error->message);
g_error_free (error);
}
g_free (cmdline); g_free (cmdline);
} }

View file

@ -291,7 +291,7 @@ net_proxy_init (NetProxy *proxy)
GSettings *settings_tmp; GSettings *settings_tmp;
ProxyMode value; ProxyMode value;
GtkWidget *widget; GtkWidget *widget;
GError *error = NULL; g_autoptr(GError) error = NULL;
guint i; guint i;
proxy = net_proxy_get_instance_private (proxy); proxy = net_proxy_get_instance_private (proxy);
@ -302,7 +302,6 @@ net_proxy_init (NetProxy *proxy)
&error); &error);
if (error != NULL) { if (error != NULL) {
g_warning ("Could not load interface file: %s", error->message); g_warning ("Could not load interface file: %s", error->message);
g_error_free (error);
return; return;
} }

View file

@ -411,7 +411,7 @@ net_vpn_class_init (NetVpnClass *klass)
static void static void
net_vpn_init (NetVpn *vpn) net_vpn_init (NetVpn *vpn)
{ {
GError *error = NULL; g_autoptr(GError) error = NULL;
GtkWidget *widget; GtkWidget *widget;
vpn = net_vpn_get_instance_private (vpn); vpn = net_vpn_get_instance_private (vpn);
@ -422,7 +422,6 @@ net_vpn_init (NetVpn *vpn)
&error); &error);
if (error != NULL) { if (error != NULL) {
g_warning ("Could not load interface file: %s", error->message); g_warning ("Could not load interface file: %s", error->message);
g_error_free (error);
return; return;
} }

View file

@ -76,12 +76,10 @@ activate_existing_cb (GObject *source_object,
GAsyncResult *res, GAsyncResult *res,
gpointer user_data) gpointer user_data)
{ {
GError *error = NULL; g_autoptr(GError) error = NULL;
if (!nm_client_activate_connection_finish (NM_CLIENT (source_object), res, &error)) { if (!nm_client_activate_connection_finish (NM_CLIENT (source_object), res, &error))
g_warning ("Failed to activate connection: (%d) %s", error->code, error->message); g_warning ("Failed to activate connection: (%d) %s", error->code, error->message);
g_error_free (error);
}
} }
static void static void
@ -89,12 +87,10 @@ activate_new_cb (GObject *source_object,
GAsyncResult *res, GAsyncResult *res,
gpointer user_data) gpointer user_data)
{ {
GError *error = NULL; g_autoptr(GError) error = NULL;
if (!nm_client_add_and_activate_connection_finish (NM_CLIENT (source_object), res, &error)) { if (!nm_client_add_and_activate_connection_finish (NM_CLIENT (source_object), res, &error))
g_warning ("Failed to add new connection: (%d) %s", error->code, error->message); g_warning ("Failed to add new connection: (%d) %s", error->code, error->message);
g_error_free (error);
}
} }
static void static void

View file

@ -57,11 +57,10 @@ validate (EAPMethod *parent, GError **error)
GtkTreeIter iter; GtkTreeIter iter;
EAPMethod *eap = NULL; EAPMethod *eap = NULL;
gboolean valid = FALSE; gboolean valid = FALSE;
GError *local = NULL; g_autoptr(GError) local_error = NULL;
if (!eap_method_validate_filepicker (parent->builder, "eap_peap_ca_cert_button", TYPE_CA_CERT, NULL, NULL, &local)) { if (!eap_method_validate_filepicker (parent->builder, "eap_peap_ca_cert_button", TYPE_CA_CERT, NULL, NULL, &local_error)) {
g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-PEAP CA certificate: %s"), local->message); g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-PEAP CA certificate: %s"), local_error->message);
g_clear_error (&local);
return FALSE; return FALSE;
} }
if (eap_method_ca_cert_required (parent->builder, "eap_peap_ca_cert_not_required_checkbox", "eap_peap_ca_cert_button")) { if (eap_method_ca_cert_required (parent->builder, "eap_peap_ca_cert_not_required_checkbox", "eap_peap_ca_cert_button")) {
@ -145,7 +144,7 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
GtkTreeModel *model; GtkTreeModel *model;
GtkTreeIter iter; GtkTreeIter iter;
int peapver_active = 0; int peapver_active = 0;
GError *error = NULL; g_autoptr(GError) error = NULL;
gboolean ca_cert_error = FALSE; gboolean ca_cert_error = FALSE;
s_8021x = nm_connection_get_setting_802_1x (connection); s_8021x = nm_connection_get_setting_802_1x (connection);
@ -164,7 +163,6 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget)); filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
if (!nm_setting_802_1x_set_ca_cert (s_8021x, filename, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error)) { if (!nm_setting_802_1x_set_ca_cert (s_8021x, filename, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error)) {
g_warning ("Couldn't read CA certificate '%s': %s", filename, error ? error->message : "(unknown)"); g_warning ("Couldn't read CA certificate '%s': %s", filename, error ? error->message : "(unknown)");
g_clear_error (&error);
ca_cert_error = TRUE; ca_cert_error = TRUE;
} }
eap_method_ca_cert_ignore_set (parent, connection, filename, ca_cert_error); eap_method_ca_cert_ignore_set (parent, connection, filename, ca_cert_error);

View file

@ -57,7 +57,9 @@ validate (EAPMethod *parent, GError **error)
NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
GtkWidget *widget; GtkWidget *widget;
const char *password, *identity; const char *password, *identity;
GError *local = NULL; g_autoptr(GError) ca_cert_error = NULL;
g_autoptr(GError) private_key_error = NULL;
g_autoptr(GError) user_cert_error = NULL;
gboolean ret = TRUE; gboolean ret = TRUE;
widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_identity_entry")); widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_identity_entry"));
@ -71,13 +73,12 @@ validate (EAPMethod *parent, GError **error)
widget_unset_error (widget); widget_unset_error (widget);
} }
if (!eap_method_validate_filepicker (parent->builder, "eap_tls_ca_cert_button", TYPE_CA_CERT, NULL, NULL, &local)) { if (!eap_method_validate_filepicker (parent->builder, "eap_tls_ca_cert_button", TYPE_CA_CERT, NULL, NULL, &ca_cert_error)) {
widget_set_error (GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_ca_cert_button"))); widget_set_error (GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_ca_cert_button")));
if (ret) { if (ret) {
g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-TLS CA certificate: %s"), local->message); g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-TLS CA certificate: %s"), ca_cert_error->message);
ret = FALSE; ret = FALSE;
} }
g_clear_error (&local);
} else if (eap_method_ca_cert_required (parent->builder, "eap_tls_ca_cert_not_required_checkbox", "eap_tls_ca_cert_button")) { } else if (eap_method_ca_cert_required (parent->builder, "eap_tls_ca_cert_not_required_checkbox", "eap_tls_ca_cert_button")) {
widget_set_error (GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_ca_cert_button"))); widget_set_error (GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_ca_cert_button")));
if (ret) { if (ret) {
@ -95,22 +96,20 @@ validate (EAPMethod *parent, GError **error)
TYPE_PRIVATE_KEY, TYPE_PRIVATE_KEY,
password, password,
&format, &format,
&local)) { &private_key_error)) {
if (ret) { if (ret) {
g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-TLS private-key: %s"), local->message); g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-TLS private-key: %s"), private_key_error->message);
ret = FALSE; ret = FALSE;
} }
g_clear_error (&local);
widget_set_error (GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_private_key_button"))); widget_set_error (GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_private_key_button")));
} }
if (format != NM_SETTING_802_1X_CK_FORMAT_PKCS12) { if (format != NM_SETTING_802_1X_CK_FORMAT_PKCS12) {
if (!eap_method_validate_filepicker (parent->builder, "eap_tls_user_cert_button", TYPE_CLIENT_CERT, NULL, NULL, &local)) { if (!eap_method_validate_filepicker (parent->builder, "eap_tls_user_cert_button", TYPE_CLIENT_CERT, NULL, NULL, &user_cert_error)) {
if (ret) { if (ret) {
g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-TLS user-certificate: %s"), local->message); g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-TLS user-certificate: %s"), user_cert_error->message);
ret = FALSE; ret = FALSE;
} }
g_clear_error (&local);
widget_set_error (GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_user_cert_button"))); widget_set_error (GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_user_cert_button")));
} }
} }
@ -166,7 +165,6 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
GtkWidget *widget, *passwd_entry; GtkWidget *widget, *passwd_entry;
char *ca_filename, *pk_filename, *cc_filename; char *ca_filename, *pk_filename, *cc_filename;
const char *password = NULL; const char *password = NULL;
GError *error = NULL;
gboolean ca_cert_error = FALSE; gboolean ca_cert_error = FALSE;
s_8021x = nm_connection_get_setting_802_1x (connection); s_8021x = nm_connection_get_setting_802_1x (connection);
@ -194,15 +192,13 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
g_assert (pk_filename); g_assert (pk_filename);
if (parent->phase2) { if (parent->phase2) {
if (!nm_setting_802_1x_set_phase2_private_key (s_8021x, pk_filename, password, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error)) { g_autoptr(GError) error = NULL;
if (!nm_setting_802_1x_set_phase2_private_key (s_8021x, pk_filename, password, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error))
g_warning ("Couldn't read phase2 private key '%s': %s", pk_filename, error ? error->message : "(unknown)"); g_warning ("Couldn't read phase2 private key '%s': %s", pk_filename, error ? error->message : "(unknown)");
g_clear_error (&error);
}
} else { } else {
if (!nm_setting_802_1x_set_private_key (s_8021x, pk_filename, password, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error)) { g_autoptr(GError) error = NULL;
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_warning ("Couldn't read private key '%s': %s", pk_filename, error ? error->message : "(unknown)");
g_clear_error (&error);
}
} }
g_free (pk_filename); g_free (pk_filename);
@ -229,15 +225,13 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
if (parent->phase2) { if (parent->phase2) {
if (!nm_setting_802_1x_set_phase2_client_cert (s_8021x, cc_filename, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error)) { g_autoptr(GError) error = NULL;
if (!nm_setting_802_1x_set_phase2_client_cert (s_8021x, cc_filename, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error))
g_warning ("Couldn't read phase2 client certificate '%s': %s", cc_filename, error ? error->message : "(unknown)"); g_warning ("Couldn't read phase2 client certificate '%s': %s", cc_filename, error ? error->message : "(unknown)");
g_clear_error (&error);
}
} else { } else {
if (!nm_setting_802_1x_set_client_cert (s_8021x, cc_filename, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error)) { g_autoptr(GError) error = NULL;
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_warning ("Couldn't read client certificate '%s': %s", cc_filename, error ? error->message : "(unknown)");
g_clear_error (&error);
}
} }
g_free (cc_filename); g_free (cc_filename);
} }
@ -249,15 +243,15 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
if (parent->phase2) { if (parent->phase2) {
g_autoptr(GError) error = NULL;
if (!nm_setting_802_1x_set_phase2_ca_cert (s_8021x, ca_filename, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error)) { if (!nm_setting_802_1x_set_phase2_ca_cert (s_8021x, ca_filename, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error)) {
g_warning ("Couldn't read phase2 CA certificate '%s': %s", ca_filename, error ? error->message : "(unknown)"); g_warning ("Couldn't read phase2 CA certificate '%s': %s", ca_filename, error ? error->message : "(unknown)");
g_clear_error (&error);
ca_cert_error = TRUE; ca_cert_error = TRUE;
} }
} else { } else {
g_autoptr(GError) error = NULL;
if (!nm_setting_802_1x_set_ca_cert (s_8021x, ca_filename, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error)) { if (!nm_setting_802_1x_set_ca_cert (s_8021x, ca_filename, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error)) {
g_warning ("Couldn't read CA certificate '%s': %s", ca_filename, error ? error->message : "(unknown)"); g_warning ("Couldn't read CA certificate '%s': %s", ca_filename, error ? error->message : "(unknown)");
g_clear_error (&error);
ca_cert_error = TRUE; ca_cert_error = TRUE;
} }
} }

View file

@ -57,11 +57,10 @@ validate (EAPMethod *parent, GError **error)
GtkTreeIter iter; GtkTreeIter iter;
EAPMethod *eap = NULL; EAPMethod *eap = NULL;
gboolean valid = FALSE; gboolean valid = FALSE;
GError *local = NULL; g_autoptr(GError) local_error = NULL;
if (!eap_method_validate_filepicker (parent->builder, "eap_ttls_ca_cert_button", TYPE_CA_CERT, NULL, NULL, &local)) { if (!eap_method_validate_filepicker (parent->builder, "eap_ttls_ca_cert_button", TYPE_CA_CERT, NULL, NULL, &local_error)) {
g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-TTLS CA certificate: %s"), local->message); g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-TTLS CA certificate: %s"), local_error->message);
g_clear_error (&local);
return FALSE; return FALSE;
} }
if (eap_method_ca_cert_required (parent->builder, "eap_ttls_ca_cert_not_required_checkbox", "eap_ttls_ca_cert_button")) { if (eap_method_ca_cert_required (parent->builder, "eap_ttls_ca_cert_not_required_checkbox", "eap_ttls_ca_cert_button")) {
@ -144,7 +143,7 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
EAPMethod *eap = NULL; EAPMethod *eap = NULL;
GtkTreeModel *model; GtkTreeModel *model;
GtkTreeIter iter; GtkTreeIter iter;
GError *error = NULL; g_autoptr(GError) error = NULL;
gboolean ca_cert_error = FALSE; gboolean ca_cert_error = FALSE;
s_8021x = nm_connection_get_setting_802_1x (connection); s_8021x = nm_connection_get_setting_802_1x (connection);
@ -169,7 +168,6 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget)); filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
if (!nm_setting_802_1x_set_ca_cert (s_8021x, filename, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error)) { if (!nm_setting_802_1x_set_ca_cert (s_8021x, filename, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error)) {
g_warning ("Couldn't read CA certificate '%s': %s", filename, error ? error->message : "(unknown)"); g_warning ("Couldn't read CA certificate '%s': %s", filename, error ? error->message : "(unknown)");
g_clear_error (&error);
ca_cert_error = TRUE; ca_cert_error = TRUE;
} }
eap_method_ca_cert_ignore_set (parent, connection, filename, ca_cert_error); eap_method_ca_cert_ignore_set (parent, connection, filename, ca_cert_error);

View file

@ -147,7 +147,7 @@ eap_method_init (gsize obj_size,
gboolean phase2) gboolean phase2)
{ {
EAPMethod *method; EAPMethod *method;
GError *error = NULL; g_autoptr(GError) error = NULL;
g_return_val_if_fail (obj_size > 0, NULL); g_return_val_if_fail (obj_size > 0, NULL);
g_return_val_if_fail (ui_resource != NULL, NULL); g_return_val_if_fail (ui_resource != NULL, NULL);
@ -169,7 +169,6 @@ eap_method_init (gsize obj_size,
if (!gtk_builder_add_from_resource (method->builder, ui_resource, &error)) { if (!gtk_builder_add_from_resource (method->builder, ui_resource, &error)) {
g_warning ("Couldn't load UI builder resource %s: %s", g_warning ("Couldn't load UI builder resource %s: %s",
ui_resource, error->message); ui_resource, error->message);
g_error_free (error);
eap_method_unref (method); eap_method_unref (method);
return NULL; return NULL;
} }

View file

@ -166,7 +166,7 @@ wireless_security_init (gsize obj_size,
const char *default_field) const char *default_field)
{ {
WirelessSecurity *sec; WirelessSecurity *sec;
GError *error = NULL; g_autoptr(GError) error = NULL;
g_return_val_if_fail (obj_size > 0, NULL); g_return_val_if_fail (obj_size > 0, NULL);
g_return_val_if_fail (ui_resource != NULL, NULL); g_return_val_if_fail (ui_resource != NULL, NULL);
@ -190,7 +190,6 @@ wireless_security_init (gsize obj_size,
if (!gtk_builder_add_from_resource (sec->builder, ui_resource, &error)) { if (!gtk_builder_add_from_resource (sec->builder, ui_resource, &error)) {
g_warning ("Couldn't load UI builder resource %s: %s", g_warning ("Couldn't load UI builder resource %s: %s",
ui_resource, error->message); ui_resource, error->message);
g_error_free (error);
wireless_security_unref (sec); wireless_security_unref (sec);
return NULL; return NULL;
} }