git: aacff95603ed - stable/13 - 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:17:33 UTC
The branch stable/13 has been updated by avg:

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

commit aacff95603ed1faa5618fff17a315c6fda53a7f1
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:14:08 +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 25091ec815f1..6c7c37308b4d 100644
--- a/sys/sys/queue.h
+++ b/sys/sys/queue.h
@@ -272,7 +272,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);			\
 	}								\
@@ -282,16 +281,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 {			\