]> sourceware.org Git - lvm2.git/commitdiff
cleanup: use safe iterator
authorZdenek Kabelac <zkabelac@redhat.com>
Fri, 22 Nov 2013 12:18:02 +0000 (13:18 +0100)
committerZdenek Kabelac <zkabelac@redhat.com>
Fri, 22 Nov 2013 20:00:55 +0000 (21:00 +0100)
Simplify code and use dm_list_iterate_items_safe() and avoid
scanning the list mutliple times.
Use dm_list_move().

lib/metadata/metadata.c

index 53d7e5ebfc6b1c2526c684191e6f1038ad514ee0..c71ec303cb2f62e55001b88579238b3b2f5998b0 100644 (file)
@@ -2809,7 +2809,7 @@ static struct volume_group *_vg_read_orphans(struct cmd_context *cmd,
        struct lvmcache_vginfo *vginfo;
        struct volume_group *vg = NULL;
        struct _vg_read_orphan_baton baton;
-       struct pv_list *pvl, *pvl_;
+       struct pv_list *pvl, *tpvl;
        struct pv_list head;
 
        dm_list_init(&head.list);
@@ -2823,15 +2823,13 @@ static struct volume_group *_vg_read_orphans(struct cmd_context *cmd,
                return_NULL;
 
        vg = fmt->orphan_vg;
-restart:
-       dm_list_iterate_items(pvl, &vg->pvs) {
-               if (pvl->pv->status & UNLABELLED_PV ) {
-                       dm_list_del(&pvl->list);
-                       dm_list_add(&head.list, &pvl->list);
-                       goto restart;
-               } else
+
+       dm_list_iterate_items_safe(pvl, tpvl, &vg->pvs)
+               if (pvl->pv->status & UNLABELLED_PV )
+                       dm_list_move(&head.list, &pvl->list);
+               else
                        pv_set_fid(pvl->pv, NULL);
-       }
+
        dm_list_init(&vg->pvs);
        vg->pv_count = 0;
        vg->extent_count = 0;
This page took 0.03536 seconds and 5 git commands to generate.