]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Use ATOMIC_VAR_INIT to initialize tid_v_base to 0
authorOndřej Surý <ondrej@sury.org>
Thu, 28 Nov 2019 10:31:02 +0000 (11:31 +0100)
committerOndřej Surý <ondrej@sury.org>
Thu, 28 Nov 2019 11:06:10 +0000 (12:06 +0100)
lib/isc/hp.c

index 4d14a54c08dca7def23943b411434baf31855ab0..746d13fc0a43cc92e40e5f829c6797be947c1a45 100644 (file)
@@ -47,6 +47,7 @@
 
 #include <isc/atomic.h>
 #include <isc/hp.h>
+#include <isc/once.h>
 #include <isc/string.h>
 #include <isc/mem.h>
 #include <isc/util.h>
@@ -61,8 +62,7 @@
 
 #define TID_UNKNOWN -1
 
-static atomic_int_fast32_t tid_v_base;
-static bool tid_v_initialized;
+static atomic_int_fast32_t tid_v_base = ATOMIC_VAR_INIT(0);
 
 #if defined(HAVE_TLS)
 #if defined(HAVE_THREAD_LOCAL)
@@ -94,10 +94,6 @@ struct isc_hp {
 
 static inline int
 tid() {
-       if (!tid_v_initialized) {
-               atomic_init(&tid_v_base, 0);
-               tid_v_initialized = true;
-       }
        if (tid_v == TID_UNKNOWN) {
                tid_v = atomic_fetch_add(&tid_v_base, 1);
                REQUIRE(tid_v < HP_MAX_THREADS);