]> git.ipfire.org Git - thirdparty/systemd.git/commit
macro: handle overflow in ALIGN_TO() somewhat reasonably 20499/head
authorLennart Poettering <lennart@poettering.net>
Fri, 20 Aug 2021 16:11:14 +0000 (18:11 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 20 Aug 2021 20:00:48 +0000 (22:00 +0200)
commitc7ed7187203ca0b348a0bb8a355b01332c446101
tree0868c624ad647bd89280e7e168ee9053e48b4b65
parenteeed637fea380c59e90e707c684e8db32714baa4
macro: handle overflow in ALIGN_TO() somewhat reasonably

The helper call rounds up to next multiple of specified boundary. If one
passes a very large value as first argument, then there might not be a
next multiple. So far we ignored that. Let's handle this now and return
SIZE_MAX in this case, as special indicator that we reached the end.

Of course, IRL this should not happen. With this new change we at least
do something somewhat reasonable, leaving it to the caller to handle it
further.
src/basic/macro.h
src/test/test-macro.c