]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: leastconn: fix build warning when building without threads on old machines
authorWilly Tarreau <w@1wt.eu>
Mon, 28 Apr 2025 14:48:42 +0000 (16:48 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 28 Apr 2025 14:50:34 +0000 (16:50 +0200)
Machines lacking CAS8B/DWCAS and emit a warning in lb_fwlc.c without
threads due to declaration ordering. Let's just move the variable
declaration into the block that uses it as a last variable. No
backport is needed.

src/lb_fwlc.c

index 354e03d17add03a5810f5f0a115e5dea8e21085e..1c5717ba69190d36a5f1f654269da4bc53b7efb9 100644 (file)
@@ -36,9 +36,6 @@ DECLARE_STATIC_POOL(pool_head_fwlc_elt, "fwlc_tree_elt", sizeof(struct fwlc_tree
  */
 static int fwlc_set_seq_and_smallest(struct lbprm *lbprm, uint64_t current, unsigned int seq, unsigned int smallest)
 {
-#if !defined(HA_CAS_IS_8B) && !defined(HA_HAVE_CAS_DW)
-       __decl_thread(static HA_SPINLOCK_T seq_lock);
-#endif
        uint64_t dst_nb = seq | ((uint64_t)smallest << 32);
        int ret;
 #if defined(HA_CAS_IS_8B)
@@ -46,6 +43,8 @@ static int fwlc_set_seq_and_smallest(struct lbprm *lbprm, uint64_t current, unsi
 #elif defined(HA_HAVE_CAS_DW)
        ret = _HA_ATOMIC_DWCAS(&lbprm->lb_seq, &current, &dst_nb);
 #else
+       __decl_thread(static HA_SPINLOCK_T seq_lock);
+
        HA_SPIN_LOCK(OTHER_LOCK, &seq_lock);
        if (lbprm->lb_seq == current) {
                lbprm->lb_seq = dst_nb;