From a4f7290c20c2ff78328c9db0b18029165cfb05b2 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 9 Jul 2019 13:26:08 -0400 Subject: [PATCH] super-intel: Fix issue with abs() being irrelevant Git-commit: a4f7290c20c2ff78328c9db0b18029165cfb05b2 Patch-mainline: mdadm-4.1+ References: jsc#SLE-10078, jsc#SLE-9348 gcc9 complains about subtracting unsigned from unsigned and code assuming the result can be negative. Signed-off-by: Jes Sorensen Signed-off-by: Coly Li --- super-intel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/super-intel.c b/super-intel.c index 4fd5e84..230e164 100644 --- a/super-intel.c +++ b/super-intel.c @@ -2875,7 +2875,7 @@ static unsigned long long calc_component_size(struct imsm_map *map, { unsigned long long component_size; unsigned long long dev_size = imsm_dev_size(dev); - unsigned long long calc_dev_size = 0; + long long calc_dev_size = 0; unsigned int member_disks = imsm_num_data_members(map); if (member_disks == 0) @@ -2889,7 +2889,7 @@ static unsigned long long calc_component_size(struct imsm_map *map, * 2048 blocks per each device. If the difference is higher it means * that array size was expanded and num_data_stripes was not updated. */ - if ((unsigned int)abs(calc_dev_size - dev_size) > + if (llabs(calc_dev_size - (long long)dev_size) > (1 << SECT_PER_MB_SHIFT) * member_disks) { component_size = dev_size / member_disks; dprintf("Invalid num_data_stripes in metadata; expected=%llu, found=%llu\n", -- 2.25.0