git: da2c88dfcf4f - main - queue: Fix STAILQ_SWAP

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Tue, 17 Dec 2024 00:14:29 UTC
The branch main has been updated by markj:

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

commit da2c88dfcf4f425e6e0a58d6df3a7c8e88d8df92
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-12-17 00:12:11 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-12-17 00:14:16 +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")
---
 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 8a1c6cd7afbb..c1fa8cd812cf 100644
--- a/sys/sys/queue.h
+++ b/sys/sys/queue.h
@@ -473,9 +473,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)