From e48063402c37d31a9aab7f23858d2b3a8a7a9979 Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Wed, 12 Sep 2012 22:54:11 +0000 Subject: [PATCH] Correctness: use __member2struct() on the correct fields. The prev-pointers point to the next-pointers of the previous element -- not the ENTRY structure. The next-pointers are stored in the ENTRY structures first, so the code would already work correctly. Still, it is more accurate to use the next-fields. To prevent misuse of __member2struct() in the future, I've got a patch that requires the pointer to be passed to this macro to be compatible with the member of the structure. I'll commit this patch after I've tested it properly. MFC after: 1 month. --- 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 3995ca06bc30..35b7539067d4 100644 --- a/sys/sys/queue.h +++ b/sys/sys/queue.h @@ -289,7 +289,7 @@ struct { \ #define STAILQ_LAST(head, type, field) \ (STAILQ_EMPTY((head)) ? \ NULL : \ - __member2struct(type, field, (head)->stqh_last)) + __member2struct(type, field.stqe_next, (head)->stqh_last)) #define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) @@ -427,7 +427,7 @@ struct { \ #define LIST_PREV(elm, head, type, field) \ ((elm)->field.le_prev == &LIST_FIRST((head)) ? \ NULL : \ - __member2struct(type, field, (elm)->field.le_prev)) + __member2struct(type, field.le_next, (elm)->field.le_prev)) #define LIST_REMOVE(elm, field) do { \ QMD_SAVELINK(oldnext, (elm)->field.le_next); \