ifcfg-rh: refactor nm_settings_plugin_add_connection() to return on error early

This commit is contained in:
Thomas Haller 2017-10-27 09:55:31 +02:00
parent 74eeb90d96
commit 304bf5563f

View file

@ -169,13 +169,17 @@ nm_settings_plugin_add_connection (NMSettingsPlugin *config,
gboolean save_to_disk,
GError **error)
{
NMSettingsPluginInterface *config_interface;
g_return_val_if_fail (config != NULL, NULL);
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
if (NM_SETTINGS_PLUGIN_GET_INTERFACE (config)->add_connection)
return NM_SETTINGS_PLUGIN_GET_INTERFACE (config)->add_connection (config, connection, save_to_disk, error);
config_interface = NM_SETTINGS_PLUGIN_GET_INTERFACE (config);
if (!config_interface->add_connection) {
g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_NOT_SUPPORTED,
"Plugin does not support adding connections");
return NULL;
}
g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_NOT_SUPPORTED,
"Plugin does not support adding connections");
return NULL;
return config_interface->add_connection (config, connection, save_to_disk, error);
}