summaryrefslogtreecommitdiffstats
path: root/lib/raid/raid.c
diff options
context:
space:
mode:
authorPetr Rockai <prockai@redhat.com>2011-08-31 15:19:19 +0000
committerPetr Rockai <prockai@redhat.com>2011-08-31 15:19:19 +0000
commit97a4b5165e172e91a38e48790c769e29360fe768 (patch)
tree5a8b78ec9b9e35c47f9ae9d701180b47e9774315 /lib/raid/raid.c
parentc0de52fd2dc7acff53f811fb2b460f9047d8a4eb (diff)
downloadlvm2-97a4b5165e172e91a38e48790c769e29360fe768.tar.gz
lvm2-97a4b5165e172e91a38e48790c769e29360fe768.tar.xz
lvm2-97a4b5165e172e91a38e48790c769e29360fe768.zip
Replace const usage of dm_config_find_node with more appropriate value-lookup
functionality. A number of bugs (copied and pasted all over the code) should disappear: - most string lookup based on dm_config_find_node would segfault when encountering a non-zero integer (the intention there was to print an error message instead) - check for required sections in metadata would have been satisfied by values as well (i.e. not sections) - encountering a section in place of expected flag value would have segfaulted (due to assumed but unchecked cn->v != NULL)
Diffstat (limited to 'lib/raid/raid.c')
-rw-r--r--lib/raid/raid.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/raid/raid.c b/lib/raid/raid.c
index f4ba9803..8bc33440 100644
--- a/lib/raid/raid.c
+++ b/lib/raid/raid.c
@@ -45,10 +45,9 @@ static int _raid_text_import_area_count(const struct dm_config_node *sn,
static int _raid_text_import_areas(struct lv_segment *seg,
const struct dm_config_node *sn,
- const struct dm_config_node *cn)
+ const struct dm_config_value *cv)
{
unsigned int s;
- const struct dm_config_value *cv;
struct logical_volume *lv1;
const char *seg_name = dm_config_parent_name(sn);
@@ -57,7 +56,7 @@ static int _raid_text_import_areas(struct lv_segment *seg,
return 0;
}
- for (cv = cn->v, s = 0; cv && s < seg->area_count; s++, cv = cv->next) {
+ for (s = 0; cv && s < seg->area_count; s++, cv = cv->next) {
if (cv->type != DM_CFG_STRING) {
log_error("Bad volume name in areas array for segment %s.", seg_name);
return 0;
@@ -104,9 +103,9 @@ static int _raid_text_import(struct lv_segment *seg,
const struct dm_config_node *sn,
struct dm_hash_table *pv_hash)
{
- const struct dm_config_node *cn;
+ const struct dm_config_value *cv;
- if (dm_config_find_node(sn, "region_size")) {
+ if (dm_config_has_node(sn, "region_size")) {
if (!dm_config_get_uint32(sn, "region_size", &seg->region_size)) {
log_error("Couldn't read 'region_size' for "
"segment %s of logical volume %s.",
@@ -114,7 +113,7 @@ static int _raid_text_import(struct lv_segment *seg,
return 0;
}
}
- if (dm_config_find_node(sn, "stripe_size")) {
+ if (dm_config_has_node(sn, "stripe_size")) {
if (!dm_config_get_uint32(sn, "stripe_size", &seg->stripe_size)) {
log_error("Couldn't read 'stripe_size' for "
"segment %s of logical volume %s.",
@@ -122,14 +121,14 @@ static int _raid_text_import(struct lv_segment *seg,
return 0;
}
}
- if (!(cn = dm_config_find_node(sn, "raids"))) {
+ if (!dm_config_get_list(sn, "raids", &cv)) {
log_error("Couldn't find RAID array for "
"segment %s of logical volume %s.",
dm_config_parent_name(sn), seg->lv->name);
return 0;
}
- if (!_raid_text_import_areas(seg, sn, cn)) {
+ if (!_raid_text_import_areas(seg, sn, cv)) {
log_error("Failed to import RAID images");
return 0;
}