summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-07-08 17:22:43 +0200
committerThomas Haller <thaller@redhat.com>2014-07-28 00:10:06 +0200
commit8510cb09f713d86c6115a26de04d03c555e0c33f (patch)
tree313996a00f20dc12610173aeeef39047d8e04570
parent6bada947bc976a1afd78f5ec8e645f2717ad1b99 (diff)
downloadNetworkManager-8510cb09f713d86c6115a26de04d03c555e0c33f.tar.gz
libnm-util: minor refactoring in NMSettingConnection:verify()
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--libnm-util/nm-setting-connection.c60
1 files changed, 31 insertions, 29 deletions
diff --git a/libnm-util/nm-setting-connection.c b/libnm-util/nm-setting-connection.c
index a8767e4048..834488683f 100644
--- a/libnm-util/nm-setting-connection.c
+++ b/libnm-util/nm-setting-connection.c
@@ -771,7 +771,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
_("property is missing"));
g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_ID);
return FALSE;
- } else if (!strlen (priv->id)) {
+ } else if (!priv->id[0]) {
g_set_error_literal (error,
NM_SETTING_CONNECTION_ERROR,
NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY,
@@ -848,38 +848,40 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
_("property is missing"));
g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_TYPE);
return FALSE;
- } else if (!strlen (priv->type)) {
- g_set_error_literal (error,
- NM_SETTING_CONNECTION_ERROR,
- NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY,
- _("property is empty"));
- g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_TYPE);
- return FALSE;
- }
-
- /* Make sure the corresponding 'type' item is present */
- if (all_settings) {
- NMSetting *s_base;
-
- s_base = nm_setting_find_in_list (all_settings, priv->type);
- if (!s_base) {
- g_set_error (error,
- NM_SETTING_CONNECTION_ERROR,
- NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND,
- _("requires presence of '%s' setting in the connection"),
- priv->type);
+ } else {
+ if (!priv->type[0]) {
+ g_set_error_literal (error,
+ NM_SETTING_CONNECTION_ERROR,
+ NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY,
+ _("property is empty"));
g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_TYPE);
return FALSE;
}
- if (!_nm_setting_is_base_type (s_base)) {
- g_set_error (error,
- NM_CONNECTION_ERROR,
- NM_CONNECTION_ERROR_CONNECTION_TYPE_INVALID,
- _("connection type '%s' is not a base type"),
- priv->type);
- g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_TYPE);
- return FALSE;
+ /* Make sure the corresponding 'type' item is present */
+ if (all_settings) {
+ NMSetting *s_base;
+
+ s_base = nm_setting_find_in_list (all_settings, priv->type);
+ if (!s_base) {
+ g_set_error (error,
+ NM_SETTING_CONNECTION_ERROR,
+ NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND,
+ _("requires presence of '%s' setting in the connection"),
+ priv->type);
+ g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_TYPE);
+ return FALSE;
+ }
+
+ if (!_nm_setting_is_base_type (s_base)) {
+ g_set_error (error,
+ NM_CONNECTION_ERROR,
+ NM_CONNECTION_ERROR_CONNECTION_TYPE_INVALID,
+ _("connection type '%s' is not a base type"),
+ priv->type);
+ g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_TYPE);
+ return FALSE;
+ }
}
}