From: Lennart Poettering Date: Tue, 9 Nov 2021 15:24:22 +0000 (+0100) Subject: repart: use LESS_BY() more X-Git-Tag: v250-rc1~320^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=184cf99a351b46f5f70353b5bffa623b84836fa1;p=thirdparty%2Fsystemd.git repart: use LESS_BY() more --- diff --git a/src/partition/repart.c b/src/partition/repart.c index 62cc8ff7ae0..482ef156ef7 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -528,16 +528,9 @@ static int free_area_compare(FreeArea *const *a, FreeArea *const*b) { } static uint64_t charge_size(uint64_t total, uint64_t amount) { - uint64_t rounded; - - assert(amount <= total); - /* Subtract the specified amount from total, rounding up to multiple of 4K if there's room */ - rounded = round_up_size(amount, 4096); - if (rounded >= total) - return 0; - - return total - rounded; + assert(amount <= total); + return LESS_BY(total, round_up_size(amount, 4096)); } static uint64_t charge_weight(uint64_t total, uint64_t amount) { @@ -1491,11 +1484,7 @@ static int determine_current_padding( offset = round_up_size(offset, 4096); next = round_down_size(next, 4096); - if (next >= offset) /* Check again, rounding might have fucked things up */ - *ret = next - offset; - else - *ret = 0; - + *ret = LESS_BY(next, offset); /* Saturated substraction, rounding might have fucked things up */ return 0; }