From: Willy Tarreau Date: Mon, 28 Apr 2025 14:48:42 +0000 (+0200) Subject: BUILD: leastconn: fix build warning when building without threads on old machines X-Git-Tag: v3.2-dev13~69 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aa49965d4e6d51f5b10c6136df9f8fa50e6477b5;p=thirdparty%2Fhaproxy.git BUILD: leastconn: fix build warning when building without threads on old machines 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. --- diff --git a/src/lb_fwlc.c b/src/lb_fwlc.c index 354e03d17..1c5717ba6 100644 --- a/src/lb_fwlc.c +++ b/src/lb_fwlc.c @@ -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, ¤t, &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;