repart: use real disk start/end for bar production
authorTom Yan <tom.ty89@gmail.com>
Sun, 19 Dec 2021 17:30:38 +0000 (01:30 +0800)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 11 Jan 2022 18:41:21 +0000 (19:41 +0100)
Partitions are not always within our aligned scope. Bar printing
involves foreign partitions as well.

Fixes #21817.

(cherry picked from commit d8daed09f37bc9f8ecb9268a4e371f65aec8b24a)

src/partition/repart.c

index 7602ac6aa86e905739dd6128e1703d8af6b41c1b..9f0fe9e10dfd76e8ef3b6af3bb0f445a3ee6c7d7 100644 (file)
@@ -2103,16 +2103,14 @@ static void context_bar_char_process_partition(
         from = p->offset;
         to = from + p->new_size;
 
-        assert(context->end >= context->start);
-        total = context->end - context->start;
+        assert(context->total > 0);
+        total = context->total;
 
-        assert(from >= context->start);
-        assert(from <= context->end);
-        x = (from - context->start) * n / total;
+        assert(from <= total);
+        x = from * n / total;
 
-        assert(to >= context->start);
-        assert(to <= context->end);
-        y = (to - context->start) * n / total;
+        assert(to <= total);
+        y = to * n / total;
 
         assert(x <= y);
         assert(y <= n);