From e6e0eb92b9bac246d3d4a1cc2b2b7c2c091cc0d0 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 27 Mar 2018 19:02:15 +0200 Subject: [PATCH] checkpoint: minor cleanup rolling back checkpoints --- src/nm-checkpoint-manager.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/nm-checkpoint-manager.c b/src/nm-checkpoint-manager.c index c43c8f0fbd..c200545c82 100644 --- a/src/nm-checkpoint-manager.c +++ b/src/nm-checkpoint-manager.c @@ -82,11 +82,20 @@ destroy_checkpoint (NMCheckpointManager *self, NMCheckpoint *checkpoint) g_object_unref (checkpoint); } +static GVariant * +rollback_checkpoint (NMCheckpointManager *self, NMCheckpoint *checkpoint) +{ + GVariant *result; + + result = nm_checkpoint_rollback (checkpoint); + destroy_checkpoint (self, checkpoint); + return result; +} + static gboolean rollback_timeout_cb (NMCheckpointManager *self) { NMCheckpoint *checkpoint, *checkpoint_safe; - GVariant *result; gint64 ts, now; self->rollback_timeout_id = 0; @@ -96,10 +105,9 @@ rollback_timeout_cb (NMCheckpointManager *self) c_list_for_each_entry_safe (checkpoint, checkpoint_safe, &self->checkpoints_lst_head, checkpoints_lst) { ts = nm_checkpoint_get_rollback_ts (checkpoint); if (ts && ts <= now) { - result = nm_checkpoint_rollback (checkpoint); - if (result) - g_variant_unref (result); - destroy_checkpoint (self, checkpoint); + gs_unref_variant GVariant *result = NULL; + + result = rollback_checkpoint (self, checkpoint); } } @@ -282,8 +290,7 @@ nm_checkpoint_manager_rollback (NMCheckpointManager *self, return FALSE; } - *results = nm_checkpoint_rollback (checkpoint); - destroy_checkpoint (self, checkpoint); + *results = rollback_checkpoint (self, checkpoint); return TRUE; }