]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
repart: make partition_max_size() return UINT64_MAX if not specified
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 4 Sep 2022 06:19:18 +0000 (15:19 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 8 Sep 2022 20:35:40 +0000 (05:35 +0900)
Previously, it did not return UINT64_MAX, but a huge value, as
`UINT64_MAX / grain_size * grain_size != UINT64_MAX`.

This also drops unnecessary conditions.

src/partition/repart.c

index 90a9c98a70023430cc3506392227f6634e37f9d5..ddbac9a596b5926fd0869115050172885328571a 100644 (file)
@@ -516,6 +516,9 @@ static uint64_t partition_max_size(const Context *context, const Partition *p) {
                 return p->current_size;
         }
 
+        if (p->size_max == UINT64_MAX)
+                return UINT64_MAX;
+
         sm = round_down_size(p->size_max, context->grain_size);
 
         if (p->current_size != UINT64_MAX)
@@ -759,7 +762,7 @@ static int context_grow_partitions_phase(
                                 p->new_size = rsz;
                                 charge = try_again = true;
 
-                        } else if (phase == PHASE_UNDERCHARGE && xsz != UINT64_MAX && xsz < share) {
+                        } else if (phase == PHASE_UNDERCHARGE && xsz < share) {
                                 /* This partition accepts less than its calculated
                                  * share. Let's assign it that, and take this partition out
                                  * of all calculations and start again. */
@@ -867,7 +870,7 @@ static int context_grow_partitions_on_free_area(Context *context, FreeArea *a) {
                 m = MAX(a->after->new_size, round_down_size(a->after->new_size + span, context->grain_size));
 
                 xsz = partition_max_size(context, a->after);
-                if (xsz != UINT64_MAX && m > xsz)
+                if (m > xsz)
                         m = xsz;
 
                 span = charge_size(context, span, m - a->after->new_size);
@@ -890,7 +893,7 @@ static int context_grow_partitions_on_free_area(Context *context, FreeArea *a) {
                         m = MAX(p->new_size, round_down_size(p->new_size + span, context->grain_size));
 
                         xsz = partition_max_size(context, p);
-                        if (xsz != UINT64_MAX && m > xsz)
+                        if (m > xsz)
                                 m = xsz;
 
                         span = charge_size(context, span, m - p->new_size);