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

Add internal error for unsupported code paths

Patch mainly helps static analyzers to better work with code paths
lvm code should never trigger.
This commit is contained in:
Zdenek Kabelac 2012-02-13 11:25:56 +00:00
parent 74b5744b4b
commit 73e62cdc11
4 changed files with 21 additions and 3 deletions

View File

@ -53,6 +53,9 @@ static char *_format_pvsegs(struct dm_pool *mem, const struct lv_segment *seg,
case AREA_UNASSIGNED:
name = "unassigned";
extent = 0;
default:
log_error(INTERNAL_ERROR "Unknown area segtype.");
return NULL;
}
if (!dm_pool_grow_object(mem, name, strlen(name))) {

View File

@ -2116,6 +2116,11 @@ struct alloc_handle *allocate_extents(struct volume_group *vg,
return NULL;
}
if (!allocatable_pvs) {
log_error(INTERNAL_ERROR "Missing allocatable pvs.");
return NULL;
}
if (vg->fid->fmt->ops->segtype_supported &&
!vg->fid->fmt->ops->segtype_supported(vg->fid, segtype)) {
log_error("Metadata format (%s) does not support required "

View File

@ -124,12 +124,18 @@ static void _lv_set_default_params(struct lvcreate_params *lp,
}
/* Set default for linear segment specific LV parameters */
static void _lv_set_default_linear_params(struct cmd_context *cmd,
static int _lv_set_default_linear_params(struct cmd_context *cmd,
struct lvcreate_params *lp)
{
lp->segtype = get_segtype_from_string(cmd, "striped");
if (!(lp->segtype = get_segtype_from_string(cmd, "striped"))) {
log_error(INTERNAL_ERROR "Segtype striped not found.");
return 0;
}
lp->stripes = 1;
lp->stripe_size = DEFAULT_STRIPESIZE * 2;
return 1;
}
/*
@ -151,7 +157,8 @@ lv_t lvm_vg_create_lv_linear(vg_t vg, const char *name, uint64_t size)
extents = extents_from_size(vg->cmd, size / SECTOR_SIZE,
vg->extent_size);
_lv_set_default_params(&lp, vg, name, extents);
_lv_set_default_linear_params(vg->cmd, &lp);
if (!_lv_set_default_linear_params(vg->cmd, &lp))
return_NULL;
if (!lv_create_single(vg, &lp))
return NULL;
lvl = find_lv_in_vg(vg, name);

View File

@ -315,6 +315,9 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
"report/pvsegs_cols_verbose",
DEFAULT_PVSEGS_COLS_VERB);
break;
default:
log_error(INTERNAL_ERROR "Unknown report type.");
return ECMD_FAILED;
}
/* If -o supplied use it, else use default for report_type */