From: Lennart Poettering Date: Fri, 2 Jun 2023 14:40:29 +0000 (+0200) Subject: tree-wide: port various pieces of code over to ROUND_UP() X-Git-Tag: v254-rc1~300^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F27902%2Fhead;p=thirdparty%2Fsystemd.git tree-wide: port various pieces of code over to ROUND_UP() There's probably more than we can convert to this. --- diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c index 04a6531dcbd..f5d2914be21 100644 --- a/src/basic/fs-util.c +++ b/src/basic/fs-util.c @@ -770,7 +770,7 @@ int unlinkat_deallocate(int fd, const char *name, UnlinkDeallocateFlags flags) { * punch-hole/truncate this to release the disk space. */ bs = MAX(st.st_blksize, 512); - l = DIV_ROUND_UP(st.st_size, bs) * bs; /* Round up to next block size */ + l = ROUND_UP(st.st_size, bs); /* Round up to next block size */ if (fallocate(truncate_fd, FALLOC_FL_PUNCH_HOLE|FALLOC_FL_KEEP_SIZE, 0, l) >= 0) return 0; /* Successfully punched a hole! 😊 */ diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c index d1f8ca381eb..f5d48236003 100644 --- a/src/libsystemd/sd-journal/journal-file.c +++ b/src/libsystemd/sd-journal/journal-file.c @@ -688,7 +688,7 @@ static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size) } /* Increase by larger blocks at once */ - new_size = DIV_ROUND_UP(new_size, FILE_SIZE_INCREASE) * FILE_SIZE_INCREASE; + new_size = ROUND_UP(new_size, FILE_SIZE_INCREASE); if (f->metrics.max_size > 0 && new_size > f->metrics.max_size) new_size = f->metrics.max_size; diff --git a/src/shared/calendarspec.c b/src/shared/calendarspec.c index 628c6202e1e..f17d97a2c10 100644 --- a/src/shared/calendarspec.c +++ b/src/shared/calendarspec.c @@ -1151,7 +1151,7 @@ static int find_matching_component( } else if (c->repeat > 0) { int k; - k = start + c->repeat * DIV_ROUND_UP(*val - start, c->repeat); + k = start + ROUND_UP(*val - start, c->repeat); if ((!d_set || k < d) && (stop < 0 || k <= stop)) { d = k;