diff mbox series

[v6,3/5] blockdev: qmp_transaction: refactor loop to classic for

Message ID 20230221154617.745341-4-vsementsov@yandex-team.ru
State New
Headers show
Series block: refactor blockdev transactions | expand

Commit Message

Vladimir Sementsov-Ogievskiy Feb. 21, 2023, 3:46 p.m. UTC
From: Vladimir Sementsov-Ogievskiy <vladimir.sementsov-ogievskiy@openvz.org>

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@openvz.org>
---
 blockdev.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/blockdev.c b/blockdev.c
index 2174ab2694..89c573a094 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2375,7 +2375,7 @@  void qmp_transaction(TransactionActionList *actions,
                      struct TransactionProperties *properties,
                      Error **errp)
 {
-    TransactionActionList *act = actions;
+    TransactionActionList *act;
     bool has_properties = !!properties;
     JobTxn *block_job_txn = NULL;
     Error *local_err = NULL;
@@ -2395,14 +2395,11 @@  void qmp_transaction(TransactionActionList *actions,
     bdrv_drain_all();
 
     /* We don't do anything in this loop that commits us to the operations */
-    while (NULL != act) {
-        TransactionAction *dev_info = NULL;
+    for (act = actions; act; act = act->next) {
+        TransactionAction *dev_info = act->value;
         const BlkActionOps *ops;
         BlkActionState *state;
 
-        dev_info = act->value;
-        act = act->next;
-
         assert(dev_info->type < ARRAY_SIZE(actions_map));
 
         ops = &actions_map[dev_info->type];