git: b14c0e102e78 - stable/14 - queue: Fix STAILQ_SWAP

From: Olivier Certner <olce_at_FreeBSD.org>
Date: Thu, 16 Jan 2025 18:08:37 UTC
The branch stable/14 has been updated by olce:

URL: https://cgit.FreeBSD.org/src/commit/?id=b14c0e102e783c24795578df33b60319c6239481

commit b14c0e102e783c24795578df33b60319c6239481
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-12-17 00:12:11 +0000
Commit:     Olivier Certner <olce@FreeBSD.org>
CommitDate: 2025-01-16 18:07:01 +0000

    queue: Fix STAILQ_SWAP
    
    The debug assertions added in commit 34740937f7a4 do not hold for a
    window in STAILQ_SWAP, so check whether the queues are empty directly.
    
    Reported by:    ler
    Fixes:          34740937f7a4 ("queue: New debug macros for STAILQ")
    
    (cherry picked from commit da2c88dfcf4f425e6e0a58d6df3a7c8e88d8df92)
---
 sys/sys/queue.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/sys/queue.h b/sys/sys/queue.h
index fee6618ee88c..be862c7ce814 100644
--- a/sys/sys/queue.h
+++ b/sys/sys/queue.h
@@ -475,9 +475,9 @@ struct {								\
 	(head1)->stqh_last = (head2)->stqh_last;			\
 	STAILQ_FIRST(head2) = swap_first;				\
 	(head2)->stqh_last = swap_last;					\
-	if (STAILQ_EMPTY(head1))					\
+	if (STAILQ_FIRST(head1) == NULL)				\
 		(head1)->stqh_last = &STAILQ_FIRST(head1);		\
-	if (STAILQ_EMPTY(head2))					\
+	if (STAILQ_FIRST(head2) == NULL)				\
 		(head2)->stqh_last = &STAILQ_FIRST(head2);		\
 } while (0)