From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49121) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2gM4-0005FG-TX for qemu-devel@nongnu.org; Wed, 10 Jun 2015 09:47:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z2gM3-0007nl-GZ for qemu-devel@nongnu.org; Wed, 10 Jun 2015 09:47:44 -0400 From: Kevin Wolf Date: Wed, 10 Jun 2015 15:47:04 +0200 Message-Id: <1433944027-28533-11-git-send-email-kwolf@redhat.com> In-Reply-To: <1433944027-28533-1-git-send-email-kwolf@redhat.com> References: <1433944027-28533-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH v2 10/13] queue.h: Add QLIST_FIX_HEAD_PTR() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: kwolf@redhat.com, berto@igalia.com, qemu-devel@nongnu.org, armbru@redhat.com, mreitz@redhat.com If the head of a list has been moved to a different memory location, the le_prev link in the first list entry has to be fixed up. Provide a macro that implements this fixup. Signed-off-by: Kevin Wolf --- include/qemu/queue.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/qemu/queue.h b/include/qemu/queue.h index f781aa2..a8d3cb8 100644 --- a/include/qemu/queue.h +++ b/include/qemu/queue.h @@ -117,6 +117,12 @@ struct { \ } \ } while (/*CONSTCOND*/0) +#define QLIST_FIX_HEAD_PTR(head, field) do { \ + if ((head)->lh_first != NULL) { \ + (head)->lh_first->field.le_prev = &(head)->lh_first; \ + } \ +} while (/*CONSTCOND*/0) + #define QLIST_INSERT_AFTER(listelm, elm, field) do { \ if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \ (listelm)->field.le_next->field.le_prev = \ -- 1.8.3.1