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>
Mon, 20 Dec 2021 13:50:08 +0000 (14:50 +0100)
Partitions are not always within our aligned scope. Bar printing
involves foreign partitions as well.

Fixes #21817.

src/partition/repart.c

index 895c0665d8905bde6fdb78cbc4ee88ef436e6642..d08f47f2c477ce83b34fd5b7e591b8570f089179 100644 (file)
@@ -2080,16 +2080,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);