]> sourceware.org Git - lvm2.git/commitdiff
Just code move of hash initialization in front of function
authorZdenek Kabelac <zkabelac@redhat.com>
Mon, 27 Feb 2012 11:40:58 +0000 (11:40 +0000)
committerZdenek Kabelac <zkabelac@redhat.com>
Mon, 27 Feb 2012 11:40:58 +0000 (11:40 +0000)
Make sure both hash tables are initialized before _read_sections() call.
Presents no functional change (since PV scan phase was not adding LV hashes),
but makes the code easier to handle mem failing case, and static analyzer is
hapier as well.

lib/format_text/import_vsn1.c

index b38892a237dd8580cd19f75450a95d965af5ab3a..046607a084ecd519a34ba88e0f5de560320000da 100644 (file)
@@ -694,6 +694,24 @@ static struct volume_group *_read_vg(struct format_instance *fid,
        if (!(vg->system_id = dm_pool_zalloc(vg->vgmem, NAME_LEN + 1)))
                goto_bad;
 
+       /*
+        * The pv hash memorises the pv section names -> pv
+        * structures.
+        */
+       if (!(pv_hash = dm_hash_create(64))) {
+               log_error("Couldn't create pv hash table.");
+               goto bad;
+       }
+
+       /*
+        * The lv hash memorises the lv section names -> lv
+        * structures.
+        */
+       if (!(lv_hash = dm_hash_create(1024))) {
+               log_error("Couldn't create lv hash table.");
+               goto bad;
+       }
+
        vgn = vgn->child;
 
        if (dm_config_get_str(vgn, "system_id", &str)) {
@@ -752,15 +770,6 @@ static struct volume_group *_read_vg(struct format_instance *fid,
                vg->mda_copies = DEFAULT_VGMETADATACOPIES;
        }
 
-       /*
-        * The pv hash memorises the pv section names -> pv
-        * structures.
-        */
-       if (!(pv_hash = dm_hash_create(64))) {
-               log_error("Couldn't create hash table.");
-               goto bad;
-       }
-
        if (!_read_sections(fid, "physical_volumes", _read_pv, vg,
                            vgn, pv_hash, lv_hash, 0, &scan_done_once)) {
                log_error("Couldn't find all physical volumes for volume "
@@ -775,15 +784,6 @@ static struct volume_group *_read_vg(struct format_instance *fid,
                goto bad;
        }
 
-       /*
-        * The lv hash memorises the lv section names -> lv
-        * structures.
-        */
-       if (!(lv_hash = dm_hash_create(1024))) {
-               log_error("Couldn't create hash table.");
-               goto bad;
-       }
-
        if (!_read_sections(fid, "logical_volumes", _read_lvnames, vg,
                            vgn, pv_hash, lv_hash, 1, NULL)) {
                log_error("Couldn't read all logical volume names for volume "
This page took 0.029561 seconds and 5 git commands to generate.