Commit e5fc9a30 authored by Thomas Haller's avatar Thomas Haller

checkpoint: don't let nm_checkpoint_new() fail

We already do error checking in nm_checkpoint_manager_create(). No need
to split it in two places. Let all error conditions be handled by
nm_checkpoint_manager_create() first, and then once we decide all is
good, nm_checkpoint_new() can no longer fail.
parent 5fb65b7f
......@@ -161,6 +161,14 @@ nm_checkpoint_manager_create (NMCheckpointManager *self,
}
}
if (!devices->len) {
g_set_error_literal (error,
NM_MANAGER_ERROR,
NM_MANAGER_ERROR_INVALID_ARGUMENTS,
"no device available");
return NULL;
}
if (!NM_FLAGS_HAS (flags, NM_CHECKPOINT_CREATE_FLAG_DESTROY_ALL)) {
for (i = 0; i < devices->len; i++) {
device = devices->pdata[i];
......@@ -175,9 +183,7 @@ nm_checkpoint_manager_create (NMCheckpointManager *self,
}
}
checkpoint = nm_checkpoint_new (manager, devices, rollback_timeout, flags, error);
if (!checkpoint)
return NULL;
checkpoint = nm_checkpoint_new (manager, devices, rollback_timeout, flags);
if (NM_FLAGS_HAS (flags, NM_CHECKPOINT_CREATE_FLAG_DESTROY_ALL))
nm_checkpoint_manager_destroy_all (self);
......
......@@ -495,7 +495,7 @@ nm_checkpoint_init (NMCheckpoint *self)
NMCheckpoint *
nm_checkpoint_new (NMManager *manager, GPtrArray *devices, guint32 rollback_timeout_s,
NMCheckpointCreateFlags flags, GError **error)
NMCheckpointCreateFlags flags)
{
NMCheckpoint *self;
NMCheckpointPrivate *priv;
......@@ -505,15 +505,7 @@ nm_checkpoint_new (NMManager *manager, GPtrArray *devices, guint32 rollback_time
g_return_val_if_fail (manager, NULL);
g_return_val_if_fail (devices, NULL);
g_return_val_if_fail (!error || !*error, NULL);
if (!devices->len) {
g_set_error_literal (error,
NM_MANAGER_ERROR,
NM_MANAGER_ERROR_INVALID_ARGUMENTS,
"no device available");
return NULL;
}
g_return_val_if_fail (devices->len > 0, NULL);
self = g_object_new (NM_TYPE_CHECKPOINT, NULL);
......
......@@ -48,7 +48,7 @@ typedef struct _NMCheckpointClass NMCheckpointClass;
GType nm_checkpoint_get_type (void);
NMCheckpoint *nm_checkpoint_new (NMManager *manager, GPtrArray *devices, guint32 rollback_timeout,
NMCheckpointCreateFlags flags, GError **error);
NMCheckpointCreateFlags flags);
typedef void (*NMCheckpointTimeoutCallback) (NMCheckpoint *self,
gpointer user_data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment