From 8510cb09f713d86c6115a26de04d03c555e0c33f Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 8 Jul 2014 17:22:43 +0200 Subject: libnm-util: minor refactoring in NMSettingConnection:verify() Signed-off-by: Thomas Haller --- libnm-util/nm-setting-connection.c | 60 ++++++++++++++++++++------------------ 1 file 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; + } } } -- cgit v1.2.1