From: Michael Olbrich Date: Tue, 4 Oct 2016 14:15:37 +0000 (+0200) Subject: list: LIST_INSERT_BEFORE: update head if necessary (#4261) X-Git-Tag: v232.2~50 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=e4818ba5276510602ff5550a1e5a058fca51e9d4;hp=5d3c70eec7861aa623adeac659ac4a6f890557d2 list: LIST_INSERT_BEFORE: update head if necessary (#4261) If the new item is inserted before the first item in the list, then the head must be updated as well. Add a test to the list unit test to check for this. --- diff --git a/src/basic/list.h b/src/basic/list.h index 5962aa421..c3771a177 100644 --- a/src/basic/list.h +++ b/src/basic/list.h @@ -142,6 +142,8 @@ } else { \ if ((_b->name##_prev = _a->name##_prev)) \ _b->name##_prev->name##_next = _b; \ + else \ + *_head = _b; \ _b->name##_next = _a; \ _a->name##_prev = _b; \ } \