summaryrefslogtreecommitdiff
path: root/lib/format1/format1.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/format1/format1.c')
-rw-r--r--lib/format1/format1.c97
1 files changed, 32 insertions, 65 deletions
diff --git a/lib/format1/format1.c b/lib/format1/format1.c
index 3354968b0..317a516ba 100644
--- a/lib/format1/format1.c
+++ b/lib/format1/format1.c
@@ -168,7 +168,6 @@ static struct volume_group *_build_vg(struct format_instance *fid,
return vg;
bad:
- stack;
dm_pool_free(mem, vg);
return NULL;
}
@@ -182,10 +181,8 @@ static struct volume_group *_format1_vg_read(struct format_instance *fid,
struct volume_group *vg = NULL;
list_init(&pvs);
- if (!mem) {
- stack;
- return NULL;
- }
+ if (!mem)
+ return_NULL;
/* Strip dev_dir if present */
vg_name = strip_dir(vg_name, fid->fmt->cmd->dev_dir);
@@ -209,10 +206,8 @@ static struct disk_list *_flatten_pv(struct format_instance *fid,
{
struct disk_list *dl = dm_pool_alloc(mem, sizeof(*dl));
- if (!dl) {
- stack;
- return NULL;
- }
+ if (!dl)
+ return_NULL;
dl->mem = mem;
dl->dev = pv->dev;
@@ -224,9 +219,8 @@ static struct disk_list *_flatten_pv(struct format_instance *fid,
!export_vg(&dl->vgd, vg) ||
!export_uuids(dl, vg) ||
!export_lvs(dl, vg, pv, dev_dir) || !calculate_layout(dl)) {
- stack;
dm_pool_free(mem, dl);
- return NULL;
+ return_NULL;
}
return dl;
@@ -241,10 +235,8 @@ static int _flatten_vg(struct format_instance *fid, struct dm_pool *mem,
struct disk_list *data;
list_iterate_items(pvl, &vg->pvs) {
- if (!(data = _flatten_pv(fid, mem, vg, pvl->pv, dev_dir))) {
- stack;
- return 0;
- }
+ if (!(data = _flatten_pv(fid, mem, vg, pvl->pv, dev_dir)))
+ return_0;
list_add(pvds, &data->list);
}
@@ -252,10 +244,8 @@ static int _flatten_vg(struct format_instance *fid, struct dm_pool *mem,
export_numbers(pvds, vg);
export_pv_act(pvds);
- if (!export_vg_number(fid, pvds, vg->name, filter)) {
- stack;
- return 0;
- }
+ if (!export_vg_number(fid, pvds, vg->name, filter))
+ return_0;
return 1;
}
@@ -267,10 +257,8 @@ static int _format1_vg_write(struct format_instance *fid, struct volume_group *v
struct list pvds;
int r = 0;
- if (!mem) {
- stack;
- return 0;
- }
+ if (!mem)
+ return_0;
list_init(&pvds);
@@ -293,25 +281,17 @@ static int _format1_pv_read(const struct format_type *fmt, const char *pv_name,
log_very_verbose("Reading physical volume data %s from disk", pv_name);
- if (!mem) {
- stack;
- return 0;
- }
+ if (!mem)
+ return_0;
- if (!(dev = dev_cache_get(pv_name, fmt->cmd->filter))) {
- stack;
- goto out;
- }
+ if (!(dev = dev_cache_get(pv_name, fmt->cmd->filter)))
+ goto_out;
- if (!(dl = read_disk(fmt, dev, mem, NULL))) {
- stack;
- goto out;
- }
+ if (!(dl = read_disk(fmt, dev, mem, NULL)))
+ goto_out;
- if (!import_pv(fmt, fmt->cmd->mem, dl->dev, NULL, pv, &dl->pvd, &dl->vgd)) {
- stack;
- goto out;
- }
+ if (!import_pv(fmt, fmt->cmd->mem, dl->dev, NULL, pv, &dl->pvd, &dl->vgd))
+ goto_out;
pv->fmt = fmt;
@@ -344,10 +324,8 @@ static int _format1_pv_setup(const struct format_type *fmt,
/*
* This works out pe_start and pe_count.
*/
- if (!calculate_extent_count(pv, extent_size, extent_count, pe_start)) {
- stack;
- return 0;
- }
+ if (!calculate_extent_count(pv, extent_size, extent_count, pe_start))
+ return_0;
/* Retain existing extent locations exactly */
if (((pe_start || extent_count) && (pe_start != pv->pe_start)) ||
@@ -390,10 +368,8 @@ static int _format1_pv_write(const struct format_type *fmt, struct physical_volu
struct lvmcache_info *info;
if (!(info = lvmcache_add(fmt->labeller, (char *) &pv->id, pv->dev,
- pv->vg_name, NULL, 0))) {
- stack;
- return 0;
- }
+ pv->vg_name, NULL, 0)))
+ return_0;
label = info->label;
info->device_size = pv->size << SECTOR_SHIFT;
info->fmt = fmt;
@@ -406,10 +382,8 @@ static int _format1_pv_write(const struct format_type *fmt, struct physical_volu
pv->pe_size = pv->pe_count = 0;
pv->pe_start = LVM1_PE_ALIGN;
- if (!(mem = dm_pool_create("lvm1 pv_write", 1024))) {
- stack;
- return 0;
- }
+ if (!(mem = dm_pool_create("lvm1 pv_write", 1024)))
+ return_0;
if (!(dl = dm_pool_alloc(mem, sizeof(*dl))))
goto_bad;
@@ -473,10 +447,8 @@ static int _format1_vg_setup(struct format_instance *fid, struct volume_group *v
static int _format1_segtype_supported(struct format_instance *fid __attribute((unused)),
const struct segment_type *segtype)
{
- if (!(segtype->flags & SEG_FORMAT1_SUPPORT)) {
- stack;
- return 0;
- }
+ if (!(segtype->flags & SEG_FORMAT1_SUPPORT))
+ return_0;
return 1;
}
@@ -494,19 +466,16 @@ static struct format_instance *_format1_create_instance(const struct format_type
struct format_instance *fid;
struct metadata_area *mda;
- if (!(fid = dm_pool_alloc(fmt->cmd->mem, sizeof(*fid)))) {
- stack;
- return NULL;
- }
+ if (!(fid = dm_pool_alloc(fmt->cmd->mem, sizeof(*fid))))
+ return_NULL;
fid->fmt = fmt;
list_init(&fid->metadata_areas);
/* Define a NULL metadata area */
if (!(mda = dm_pool_alloc(fmt->cmd->mem, sizeof(*mda)))) {
- stack;
dm_pool_free(fmt->cmd->mem, fid);
- return NULL;
+ return_NULL;
}
mda->ops = &_metadata_format1_ops;
@@ -547,10 +516,8 @@ struct format_type *init_format(struct cmd_context *cmd)
{
struct format_type *fmt = dm_malloc(sizeof(*fmt));
- if (!fmt) {
- stack;
- return NULL;
- }
+ if (!fmt)
+ return_NULL;
fmt->cmd = cmd;
fmt->ops = &_format1_ops;