diff options
author | Zdenek Kabelac <zkabelac@redhat.com> | 2012-02-13 11:25:56 +0000 |
---|---|---|
committer | Zdenek Kabelac <zkabelac@redhat.com> | 2012-02-13 11:25:56 +0000 |
commit | 73e62cdc110e644616acf4a10b693768818a8ba5 (patch) | |
tree | f969ae3482edc3f7d27cac17cf321a7438129c94 /liblvm/lvm_lv.c | |
parent | 74b5744b4bdcef20589fbc987dca61c33a5a33d5 (diff) | |
download | lvm2-73e62cdc110e644616acf4a10b693768818a8ba5.tar.gz |
Add internal error for unsupported code paths
Patch mainly helps static analyzers to better work with code paths
lvm code should never trigger.
Diffstat (limited to 'liblvm/lvm_lv.c')
-rw-r--r-- | liblvm/lvm_lv.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/liblvm/lvm_lv.c b/liblvm/lvm_lv.c index c535caf9d..f8ef2f16e 100644 --- a/liblvm/lvm_lv.c +++ b/liblvm/lvm_lv.c @@ -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); |