]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: bug: make BUG_ON() fall back to ASSUME
authorWilly Tarreau <w@1wt.eu>
Thu, 7 Nov 2024 10:12:40 +0000 (11:12 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 17 Dec 2024 16:39:12 +0000 (17:39 +0100)
commit7b6acb6a5153569444de7b71db6714b5cbd1738f
tree30141ea32bceac7781e6baca102fd3b03669951a
parent63798088b300688af2fb480c5c7b91a1ca9970c5
MINOR: bug: make BUG_ON() fall back to ASSUME

When the strict level is zero and BUG_ON() is not implemented, some
possible null-deref warnings are emitted again because some were
covering for these cases. Let's make it fall back to ASSUME() so that
the compiler continues to know that the tested expression never happens.
It also allows to further optimize certain functions by helping the
compiler eliminate certain tests for impossible values. However it
requires that the expression is really evaluated before passing the
result through ASSUME() otherwise it was shown that gcc-11 and above
will fail to evaluate its implications and will continue to emit the
null-deref warnings in case the expression is non-trivial (e.g. it
has multiple terms).

We don't do it for BUG_ON_HOT() however because the extra cost of
evaluating the condition is generally not welcome in fast paths,
particularly when that BUG_ON_HOT() was kept disabled for
performance reasons.
include/haproxy/bug.h