diff options
author | Lennart Poettering <lennart@poettering.net> | 2021-11-09 16:24:22 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2021-11-09 16:24:22 +0100 |
commit | 184cf99a351b46f5f70353b5bffa623b84836fa1 (patch) | |
tree | 81befc28f0d8ecde2ab4160b805e195bf9942535 /src/partition/repart.c | |
parent | Revert "CI: disable opensuse mkosi CI" (diff) | |
download | systemd-184cf99a351b46f5f70353b5bffa623b84836fa1.tar.xz systemd-184cf99a351b46f5f70353b5bffa623b84836fa1.zip |
repart: use LESS_BY() more
Diffstat (limited to 'src/partition/repart.c')
-rw-r--r-- | src/partition/repart.c | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/src/partition/repart.c b/src/partition/repart.c index 62cc8ff7ae..482ef156ef 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; } |