summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2015-11-13 09:49:59 +0100
committerZdenek Kabelac <zkabelac@redhat.com>2015-11-13 11:18:27 +0100
commitb2e13ac552b6209c02c6e2c00aa0db2018135523 (patch)
tree790760ceebbbe75eeb7d3359eb7ddb0c2f1c6834
parent3089f5ab15dbab151f18067acbcdf582a90d932d (diff)
downloadlvm2-b2e13ac552b6209c02c6e2c00aa0db2018135523.tar.gz
coverity: add few internal errors
Mark impossible paths with internal errors. Also replace 'strcmp() with more readable seg_is...()
-rw-r--r--lib/metadata/lv_manip.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 0022cb744..2582ed556 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -4903,7 +4903,12 @@ static int _lvresize_adjust_extents(struct cmd_context *cmd, struct logical_volu
return 0;
}
- if (!strcmp(mirr_seg->segtype->name, _lv_type_names[LV_TYPE_RAID10])) {
+ if (seg_is_raid10(mirr_seg)) {
+ if (!seg_mirrors) {
+ log_error(INTERNAL_ERROR "Missing mirror segments for %s.",
+ display_lvname(lv));
+ return 0;
+ }
/* FIXME Warn if command line values are being overridden? */
lp->stripes = mirr_seg->area_count / seg_mirrors;
lp->stripe_size = mirr_seg->stripe_size;
@@ -4916,7 +4921,7 @@ static int _lvresize_adjust_extents(struct cmd_context *cmd, struct logical_volu
/* Allow through "striped" and RAID 4/5/6/10 */
if (!seg_is_striped(seg) &&
(!seg_is_raid(seg) || seg_is_mirrored(seg)) &&
- strcmp(seg->segtype->name, _lv_type_names[LV_TYPE_RAID10]))
+ !seg_is_raid10(seg))
continue;
sz = seg->stripe_size;
@@ -5748,7 +5753,11 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
lv->name);
return 0;
} else if (lv_is_thin_volume(lv)) {
- pool_lv = first_seg(lv)->pool_lv;
+ if (!(pool_lv = first_seg(lv)->pool_lv)) {
+ log_error(INTERNAL_ERROR "Thin LV %s without pool.",
+ display_lvname(lv));
+ return 0;
+ }
lock_lv = pool_lv;
}