]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: debug: add a new DISGUISE() macro to pass a value as identity
authorWilly Tarreau <w@1wt.eu>
Sat, 14 Mar 2020 09:42:26 +0000 (10:42 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 14 Mar 2020 09:52:46 +0000 (10:52 +0100)
This does exactly the same as ALREADY_CHECKED() but does it inline,
returning an identical copy of the scalar variable without letting
the compiler know how it might have been transformed. This can
forcefully disable certain null-pointer checks or result checks when
known undesirable. Typically forcing a crash with *(DISGUISE(NULL))=0
will not cause a null-deref warning.

include/common/compiler.h

index 7b086e310c454e034023a9d4ffa0a2d61924ad49..5578a58bc50084b2f5a5594bd9bb62650b6664c4 100644 (file)
  */
 #define ALREADY_CHECKED(p) do { asm("" : "=rm"(p) : "0"(p)); } while (0)
 
+/* same as above but to be used to pass the input value to the output but
+ * without letting the compiler know about its initial properties.
+ */
+#define DISGUISE(v) ({ typeof(v) __v = (v); ALREADY_CHECKED(__v); __v; })
+
 /*
  * Gcc >= 3 provides the ability for the program to give hints to the
  * compiler about what branch of an if is most likely to be taken. This