From: Yu Watanabe Date: Sun, 4 Sep 2022 06:19:18 +0000 (+0900) Subject: repart: make partition_max_size() return UINT64_MAX if not specified X-Git-Tag: v252-rc1~222^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=822d9b9adcfe00496d273a84ef89c692fb89ae00;p=thirdparty%2Fsystemd.git repart: make partition_max_size() return UINT64_MAX if not specified 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. --- diff --git a/src/partition/repart.c b/src/partition/repart.c index 90a9c98a700..ddbac9a596b 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -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);