git: 7963d46bb8cb - stable/12 - sys/queue.h: move trashing from SLIST_REMOVE to REMOVE_AFTER, REMOVE_HEAD

From: Andriy Gapon <avg_at_FreeBSD.org>
Date: Wed, 29 Dec 2021 08:22:57 UTC
The branch stable/12 has been updated by avg:

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

commit 7963d46bb8cbe709c61081f7bf24093f1160b240
Author:     Andriy Gapon <avg@FreeBSD.org>
AuthorDate: 2021-12-15 11:27:49 +0000
Commit:     Andriy Gapon <avg@FreeBSD.org>
CommitDate: 2021-12-29 08:22:52 +0000

    sys/queue.h: move trashing from SLIST_REMOVE to REMOVE_AFTER, REMOVE_HEAD
    
    SLIST_REMOVE calls either REMOVE_AFTER or REMOVE_HEAD to do the job.
    But those two macros can be used independently as well.
    
    (cherry picked from commit 5dab06a003189ebb017810bdbf3b3c2f074afd3e)
---
 sys/sys/queue.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sys/sys/queue.h b/sys/sys/queue.h
index 5e12299e01c6..d4eab4642992 100644
--- a/sys/sys/queue.h
+++ b/sys/sys/queue.h
@@ -275,7 +275,6 @@ struct {								\
 #define	SLIST_NEXT(elm, field)	((elm)->field.sle_next)
 
 #define	SLIST_REMOVE(head, elm, type, field) do {			\
-	QMD_SAVELINK(oldnext, (elm)->field.sle_next);			\
 	if (SLIST_FIRST((head)) == (elm)) {				\
 		SLIST_REMOVE_HEAD((head), field);			\
 	}								\
@@ -285,16 +284,19 @@ struct {								\
 			curelm = SLIST_NEXT(curelm, field);		\
 		SLIST_REMOVE_AFTER(curelm, field);			\
 	}								\
-	TRASHIT(*oldnext);						\
 } while (0)
 
 #define SLIST_REMOVE_AFTER(elm, field) do {				\
+	QMD_SAVELINK(oldnext, SLIST_NEXT(elm, field)->field.sle_next);	\
 	SLIST_NEXT(elm, field) =					\
 	    SLIST_NEXT(SLIST_NEXT(elm, field), field);			\
+	TRASHIT(*oldnext);						\
 } while (0)
 
 #define	SLIST_REMOVE_HEAD(head, field) do {				\
+	QMD_SAVELINK(oldnext, SLIST_FIRST(head)->field.sle_next);	\
 	SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field);	\
+	TRASHIT(*oldnext);						\
 } while (0)
 
 #define	SLIST_REMOVE_PREVPTR(prevp, elm, field) do {			\