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>
Thu, 17 Apr 2025 15:04:35 +0000 (17:04 +0200)
commitb110d150bf59e418ca3508e5f80e46b8e22d53f1
tree922b67afa3394d150769c53db3a1a57fb2bd6cbd
parent04121a85eb6cdb4c437180c96d006759f61bc53f
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().

(cherry picked from commit 63798088b300688af2fb480c5c7b91a1ca9970c5)
Signed-off-by: Willy Tarreau <w@1wt.eu>
include/haproxy/compiler.h