From: Kevin Wolf Date: Wed, 10 Jun 2015 11:47:35 +0000 (+0200) Subject: queue.h: Add QLIST_FIX_HEAD_PTR() X-Git-Tag: v2.4.0-rc0~75^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ae81693004fd95f7013e42811944707a92948d9a;p=thirdparty%2Fqemu.git queue.h: Add QLIST_FIX_HEAD_PTR() 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 Reviewed-by: Eric Blake Reviewed-by: Max Reitz --- diff --git a/include/qemu/queue.h b/include/qemu/queue.h index f781aa20a83..a8d3cb8e630 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 = \