]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
macro: upgrade ref counting overflow check assert() → assert_se()
authorLennart Poettering <lennart@poettering.net>
Wed, 20 Apr 2022 20:10:43 +0000 (22:10 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 20 Apr 2022 23:56:32 +0000 (08:56 +0900)
The overflow check for ref counting should not be subject to NDEBUG,
hence upgrade assert() → assert_se(). (The check for zero is an
immediate bug in our code, and should be impossible to trigger, hence
it's fine if the check is optimized away if people are crazy enough to
set NDEBUG, so that can stay assert())

https://github.com/systemd/systemd/pull/23099#discussion_r854341850

src/basic/macro.h

index 6e3966ff486687784dbda4d074145c03e7790a24..3bf982803d525ffd5c9ba8098e600b63f5dc7bfb 100644 (file)
@@ -399,7 +399,7 @@ static inline int __coverity_check_and_return__(int condition) {
                 /* For type check. */                           \
                 unsigned *q = &p->n_ref;                        \
                 assert(*q > 0);                                 \
-                assert(*q < UINT_MAX);                          \
+                assert_se(*q < UINT_MAX);                       \
                                                                 \
                 (*q)++;                                         \
                 return p;                                       \