]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
DEBUG: move the tainted stuff to bug.h for easier inclusion
authorWilly Tarreau <w@1wt.eu>
Fri, 25 Feb 2022 09:10:00 +0000 (10:10 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 25 Feb 2022 10:55:38 +0000 (11:55 +0100)
The functions needed to manipulate the "tainted" flags were located in
too high a level to be callable from the lower code layers. Let's move
them to bug.h.

include/haproxy/bug.h
include/haproxy/global.h
src/haproxy.c

index 52a1ebe6b4bf3894432608c816f033e5b4915cd6..ebd4a0e58364ff675e22891b6d59fd95d93917a5 100644 (file)
@@ -28,6 +28,7 @@
 #ifndef _HAPROXY_BUG_H
 #define _HAPROXY_BUG_H
 
+#include <haproxy/atomic.h>
 #include <haproxy/compiler.h>
 
 /* quick debugging hack, should really be removed ASAP */
                *__x = NULL;                                            \
        } while (0)
 
+
+/* handle 'tainted' status */
+enum tainted_flags {
+       TAINTED_CONFIG_EXP_KW_DECLARED = 0x00000001,
+       TAINTED_ACTION_EXP_EXECUTED    = 0x00000002,
+       TAINTED_CLI_EXPERT_MODE        = 0x00000004,
+       TAINTED_CLI_EXPERIMENTAL_MODE  = 0x00000008,
+};
+
+/* this is a bit field made of TAINTED_*, and is declared in haproxy.c */
+extern unsigned int tainted;
+
+static inline void mark_tainted(const enum tainted_flags flag)
+{
+       HA_ATOMIC_OR(&tainted, flag);
+}
+
+static inline unsigned int get_tainted()
+{
+       return HA_ATOMIC_LOAD(&tainted);
+}
+
 #if defined(DEBUG_MEM_STATS)
 #include <stdlib.h>
 #include <string.h>
index 03c21d535ac584269512c87dd3f4b021da1461d4..9d9a7fc483163a3952760b2cfc8d0131ce74d6ee 100644 (file)
@@ -82,16 +82,6 @@ static inline unsigned long proc_mask(unsigned long mask)
        return mask ? mask : 1;
 }
 
-/* handle 'tainted' status */
-enum tainted_flags {
-       TAINTED_CONFIG_EXP_KW_DECLARED = 0x1,
-       TAINTED_ACTION_EXP_EXECUTED    = 0x2,
-       TAINTED_CLI_EXPERT_MODE        = 0x4,
-       TAINTED_CLI_EXPERIMENTAL_MODE  = 0x8,
-};
-void mark_tainted(const enum tainted_flags flag);
-unsigned int get_tainted(void);
-
 extern unsigned int experimental_directives_allowed;
 
 struct cfg_keyword;
index 7a659f798c5064b8ffb9ae9ddb72cf364769ae4a..0da19ccdf6e2508c7883098df7cbce934e9f04cb 100644 (file)
@@ -261,7 +261,7 @@ static void *run_thread_poll_loop(void *data);
 unsigned int warned = 0;
 
 /* set if experimental features have been used for the current process */
-static unsigned int tainted = 0;
+unsigned int tainted = 0;
 
 unsigned int experimental_directives_allowed = 0;
 
@@ -1449,17 +1449,6 @@ static int check_if_maxsock_permitted(int maxsock)
        return ret == 0;
 }
 
-void mark_tainted(const enum tainted_flags flag)
-{
-       HA_ATOMIC_OR(&tainted, flag);
-}
-
-unsigned int get_tainted()
-{
-       return HA_ATOMIC_LOAD(&tainted);
-}
-
-
 /* This performs th every basic early initialization at the end of the PREPARE
  * init stage. It may only assume that list heads are initialized, but not that
  * anything else is correct. It will initialize a number of variables that