]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: compiler: add ASSUME_NONNULL() to tell the compiler a pointer is valid
authorWilly Tarreau <w@1wt.eu>
Tue, 17 Dec 2024 09:42:07 +0000 (10:42 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 17 Dec 2024 15:46:46 +0000 (16:46 +0100)
commit63798088b300688af2fb480c5c7b91a1ca9970c5
tree6cf808abe63727fd81b0c15757ae404dff3ebca7
parent2ce63b7b17c45e31ef8c3dec33b9b54aea656154
MINOR: compiler: add ASSUME_NONNULL() to tell the compiler a pointer is valid

At plenty of places we have ALREADY_CHECKED() or DISGUISE() on a pointer
just to avoid "possibly null-deref" warnings. These ones have the side
effect of weakening optimizations by passing through an assembly step.
Using ASSUME_NONNULL() we can avoid that extra step. And when the
__builtin_unreachable() builtin is not present, we fall back to the old
method using assembly. The macro returns the input value so that it may
be used both as a declarative way to claim non-nullity or directly inside
an expression like DISGUISE().
include/haproxy/compiler.h