diff options
author | Jonathan Earl Brassow <jbrassow@redhat.com> | 2011-08-11 21:32:18 +0000 |
---|---|---|
committer | Jonathan Earl Brassow <jbrassow@redhat.com> | 2011-08-11 21:32:18 +0000 |
commit | a22515c87f2aac78649f87d532d6311235a4a0a2 (patch) | |
tree | fc2ca9f200346f34f2d526cf0350680cda9f27ef /lib | |
parent | 5bedb7a5e0d4c4169362084e5820f3ca9aba1117 (diff) | |
download | lvm2-a22515c87f2aac78649f87d532d6311235a4a0a2.tar.gz lvm2-a22515c87f2aac78649f87d532d6311235a4a0a2.tar.xz lvm2-a22515c87f2aac78649f87d532d6311235a4a0a2.zip |
Various code clean-ups (s/malloc/zalloc/, new msgs, etc)
Fix a couple more issues that kabi found.
- Add some error messages in failure cases
- s/malloc/zalloc/
- use vg->vgmem for lv names instead of vg->cmd->mem
Diffstat (limited to 'lib')
-rw-r--r-- | lib/metadata/raid_manip.c | 6 | ||||
-rw-r--r-- | lib/raid/raid.c | 8 |
2 files changed, 8 insertions, 6 deletions
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c index 1a8726a4..5b9c542b 100644 --- a/lib/metadata/raid_manip.c +++ b/lib/metadata/raid_manip.c @@ -242,7 +242,7 @@ static int _extract_image_components(struct lv_segment *seg, uint32_t idx, { int len; char *tmp_name; - struct cmd_context *cmd = seg->lv->vg->cmd; + struct volume_group *vg = seg->lv->vg; struct logical_volume *data_lv = seg_lv(seg, idx); struct logical_volume *meta_lv = seg_metalv(seg, idx); @@ -262,14 +262,14 @@ static int _extract_image_components(struct lv_segment *seg, uint32_t idx, seg_metatype(seg, idx) = AREA_UNASSIGNED; len = strlen(meta_lv->name) + strlen("_extracted") + 1; - tmp_name = dm_pool_alloc(cmd->mem, len); + tmp_name = dm_pool_alloc(vg->vgmem, len); if (!tmp_name) return_0; sprintf(tmp_name, "%s_extracted", meta_lv->name); meta_lv->name = tmp_name; len = strlen(data_lv->name) + strlen("_extracted") + 1; - tmp_name = dm_pool_alloc(cmd->mem, len); + tmp_name = dm_pool_alloc(vg->vgmem, len); if (!tmp_name) return_0; sprintf(tmp_name, "%s_extracted", data_lv->name); diff --git a/lib/raid/raid.c b/lib/raid/raid.c index da9f12b1..964d615f 100644 --- a/lib/raid/raid.c +++ b/lib/raid/raid.c @@ -321,11 +321,13 @@ static struct segtype_handler _raid_ops = { static struct segment_type *init_raid_segtype(struct cmd_context *cmd, const char *raid_type) { - struct segment_type *segtype = dm_malloc(sizeof(*segtype)); + struct segment_type *segtype = dm_zalloc(sizeof(*segtype)); - if (!segtype) + if (!segtype) { + log_error("Failed to allocate memory for %s segtype", + raid_type); return_NULL; - + } segtype->cmd = cmd; segtype->flags = SEG_RAID; |