1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

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.
This commit is contained in:
Zdenek Kabelac 2012-02-27 11:40:58 +00:00
parent b9141fcefa
commit d2a3352755

View 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))) if (!(vg->system_id = dm_pool_zalloc(vg->vgmem, NAME_LEN + 1)))
goto_bad; 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; vgn = vgn->child;
if (dm_config_get_str(vgn, "system_id", &str)) { 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; 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, if (!_read_sections(fid, "physical_volumes", _read_pv, vg,
vgn, pv_hash, lv_hash, 0, &scan_done_once)) { vgn, pv_hash, lv_hash, 0, &scan_done_once)) {
log_error("Couldn't find all physical volumes for volume " 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; 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, if (!_read_sections(fid, "logical_volumes", _read_lvnames, vg,
vgn, pv_hash, lv_hash, 1, NULL)) { vgn, pv_hash, lv_hash, 1, NULL)) {
log_error("Couldn't read all logical volume names for volume " log_error("Couldn't read all logical volume names for volume "