settings: drop redundant can_commit() virtual functions

The only implementation of can_commit() was ifcfg-rh, which
bails out with complex routes.

Note that the only caller of can_commit() (update_auth_cb()),
immidiately afterwards called nm_settings_connection_commit_changes(),
which, a few layers down in nms_ifcfg_rh_writer_write_connection()
as first thing errors out in presence of complex routes.

The check was redundant.

In general, a can_commit() function before a commit_changes() makes
no sense, because commit_changes() can just fail with error.
This commit is contained in:
Thomas Haller 2017-10-20 21:05:22 +02:00
parent 18048ab20c
commit 717e4f8d25
3 changed files with 0 additions and 28 deletions

View file

@ -1668,7 +1668,6 @@ update_auth_cb (NMSettingsConnection *self,
gpointer data)
{
UpdateInfo *info = data;
NMSettingsConnectionClass *klass;
NMSettingsConnectionCommitReason commit_reason;
gs_free_error GError *local = NULL;
@ -1723,12 +1722,6 @@ update_auth_cb (NMSettingsConnection *self,
goto out;
}
klass = NM_SETTINGS_CONNECTION_GET_CLASS (self);
if (klass->can_commit) {
if (!klass->can_commit (self, &local))
goto out;
}
commit_reason = NM_SETTINGS_CONNECTION_COMMIT_REASON_USER_ACTION;
if ( info->new_settings
&& !nm_streq0 (nm_connection_get_id (NM_CONNECTION (self)),

View file

@ -104,9 +104,6 @@ struct _NMSettingsConnection {
struct _NMSettingsConnectionClass {
NMExportedObjectClass parent;
gboolean (*can_commit) (NMSettingsConnection *self,
GError **error);
gboolean (*commit_changes) (NMSettingsConnection *self,
NMConnection *new_connection,
NMSettingsConnectionCommitReason commit_reason,

View file

@ -306,23 +306,6 @@ nm_ifcfg_connection_get_unrecognized_spec (NMIfcfgConnection *self)
return NM_IFCFG_CONNECTION_GET_PRIVATE (self)->unrecognized_spec;
}
static gboolean
can_commit (NMSettingsConnection *connection,
GError **error)
{
const char *filename;
filename = nm_settings_connection_get_filename (connection);
if ( filename
&& utils_has_complex_routes (filename)) {
g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Cannot modify a connection that has an associated 'rule-' or 'rule6-' file");
return FALSE;
}
return TRUE;
}
static gboolean
commit_changes (NMSettingsConnection *connection,
NMConnection *new_connection,
@ -524,7 +507,6 @@ nm_ifcfg_connection_class_init (NMIfcfgConnectionClass *ifcfg_connection_class)
object_class->dispose = dispose;
settings_class->delete = delete;
settings_class->can_commit = can_commit;
settings_class->commit_changes = commit_changes;
obj_properties[PROP_UNMANAGED_SPEC] =