From 4a727a3ccd178d4762f0b7a8a48a24f7667e8c51 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 16 Mar 2017 00:51:52 +0100 Subject: [PATCH] raid: use 64bit arithmetic Coverity - keep multiplication for size cals in 64bit (otherwise it's just 32b x 32b) --- lib/metadata/raid_manip.c | 4 ++-- lib/report/report.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c index 9f0de4cc8..720337be1 100644 --- a/lib/metadata/raid_manip.c +++ b/lib/metadata/raid_manip.c @@ -1690,7 +1690,7 @@ static int _reshape_adjust_to_size(struct logical_volume *lv, /* Externally visible LV size w/o reshape space */ lv->le_count = seg->len = new_le_count; - lv->size = (lv->le_count - new_image_count * _reshape_len_per_dev(seg)) * lv->vg->extent_size; + lv->size = (uint64_t) (lv->le_count - new_image_count * _reshape_len_per_dev(seg)) * lv->vg->extent_size; /* seg->area_len does not change */ if (old_image_count < new_image_count) { @@ -1861,7 +1861,7 @@ static int _raid_reshape_remove_images(struct logical_volume *lv, reduced_le_count -= seg->reshape_len * _data_rimages_count(seg, new_image_count); current_le_count = lv->le_count - seg->reshape_len * _data_rimages_count(seg, old_image_count); - extend_le_count = current_le_count * current_le_count / reduced_le_count; + extend_le_count = (uint32_t)((uint64_t) current_le_count * current_le_count / reduced_le_count); log_warn("WARNING: Removing stripes from active%s logical " "volume %s will shrink it from %s to %s!", info.open_count ? " and open" : "", display_lvname(lv), diff --git a/lib/report/report.c b/lib/report/report.c index fcb9e3367..1421b31fa 100644 --- a/lib/report/report.c +++ b/lib/report/report.c @@ -2582,7 +2582,7 @@ static int _segdata_offset(struct dm_report *rh, struct dm_pool *mem, if (lv_raid_data_offset(lv, &data_offset)) { if (new_data_offset && !lv_raid_image_in_sync(seg->lv)) - data_offset = data_offset ? 0 : seg->reshape_len * lv->vg->extent_size; + data_offset = data_offset ? 0 : (uint64_t) seg->reshape_len * lv->vg->extent_size; return dm_report_field_uint64(rh, field, &data_offset); } -- 2.43.5