From 7d3e856e824ce54f8e768df3ffde2b25c8c21d1d Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 20 Apr 2022 22:10:43 +0200 Subject: [PATCH] =?utf8?q?macro:=20upgrade=20ref=20counting=20overflow=20c?= =?utf8?q?heck=20assert()=20=E2=86=92=20assert=5Fse()?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basic/macro.h b/src/basic/macro.h index 6e3966ff486..3bf982803d5 100644 --- a/src/basic/macro.h +++ b/src/basic/macro.h @@ -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; \ -- 2.47.3