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 | |
parent | 7a0895c2eb6c3e2573f246b93a61a6b4a2aa44d3 (diff) | |
download | systemd-184cf99a351b46f5f70353b5bffa623b84836fa1.tar.gz |
repart: use LESS_BY() more
Diffstat (limited to 'src/partition')
-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; } |