[network-manager-vpnc] properties: don't overwrite a GError and use real GError domains
- From: Dan Williams <dcbw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-vpnc] properties: don't overwrite a GError and use real GError domains
- Date: Thu, 10 Apr 2014 17:45:41 +0000 (UTC)
commit 6435eeca2fee87ff5241865526f6c5fe393cd1e7
Author: Dan Williams <dcbw redhat com>
Date: Thu Apr 10 12:34:35 2014 -0500
properties: don't overwrite a GError and use real GError domains
Fixes warnings when importing connections.
properties/nm-vpnc.c | 33 +++++++++++++++++++++++++++------
1 files changed, 27 insertions(+), 6 deletions(-)
---
diff --git a/properties/nm-vpnc.c b/properties/nm-vpnc.c
index 8c982dd..909c61b 100644
--- a/properties/nm-vpnc.c
+++ b/properties/nm-vpnc.c
@@ -1296,6 +1296,24 @@ decrypt_cisco_key (const char* enc_key)
return key;
}
+typedef enum {
+ NM_VPNC_IMPORT_ERROR_UNKNOWN = 0,
+ NM_VPNC_IMPORT_ERROR_NOT_VPNC,
+ NM_VPNC_IMPORT_ERROR_BAD_DATA,
+} NMVpncImportError;
+
+#define NM_VPNC_IMPORT_ERROR nm_vpnc_import_error_quark ()
+
+static GQuark
+nm_vpnc_import_error_quark (void)
+{
+ static GQuark quark = 0;
+
+ if (G_UNLIKELY (quark == 0))
+ quark = g_quark_from_static_string ("nm-vpnc-import-error-quark");
+ return quark;
+}
+
static NMConnection *
import (NMVpnPluginUiInterface *iface, const char *path, GError **error)
{
@@ -1311,11 +1329,8 @@ import (NMVpnPluginUiInterface *iface, const char *path, GError **error)
gboolean found;
keyfile = g_key_file_new ();
- if (!g_key_file_load_from_file (keyfile, path, 0, error)) {
- g_set_error (error, 0, 0, "does not look like a %s VPN connection (parse failed)",
- VPNC_PLUGIN_NAME);
+ if (!g_key_file_load_from_file (keyfile, path, 0, error))
goto error;
- }
connection = nm_connection_new ();
s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ());
@@ -1334,7 +1349,10 @@ import (NMVpnPluginUiInterface *iface, const char *path, GError **error)
nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_GATEWAY, buf);
g_free (buf);
} else {
- g_set_error (error, 0, 0, "does not look like a %s VPN connection (no Host)",
+ g_set_error (error,
+ NM_VPNC_IMPORT_ERROR,
+ NM_VPNC_IMPORT_ERROR_NOT_VPNC,
+ "does not look like a %s VPN connection (no Host)",
VPNC_PLUGIN_NAME);
goto error;
}
@@ -1345,7 +1363,10 @@ import (NMVpnPluginUiInterface *iface, const char *path, GError **error)
nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_ID, buf);
g_free (buf);
} else {
- g_set_error (error, 0, 0, "does not look like a %s VPN connection (no GroupName)",
+ g_set_error (error,
+ NM_VPNC_IMPORT_ERROR,
+ NM_VPNC_IMPORT_ERROR_BAD_DATA,
+ "does not look like a %s VPN connection (no GroupName)",
VPNC_PLUGIN_NAME);
goto error;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]