From: Zdenek Kabelac Date: Mon, 27 Feb 2012 11:40:58 +0000 (+0000) Subject: Just code move of hash initialization in front of function X-Git-Tag: v2_02_96~290 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=d2a335275582bb95a2274b1c6f50de9ffe0f3cf9;p=lvm2.git Just code move of hash initialization in front of function 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. --- diff --git a/lib/format_text/import_vsn1.c b/lib/format_text/import_vsn1.c index b38892a23..046607a08 100644 --- a/lib/format_text/import_vsn1.c +++ b/lib/format_text/import_vsn1.c @@ -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 "