Skip to content

Commit e9335dd

Browse files
committed
shims: correct list macros
This adjusts the `LIST_ENTRY` to define the structure correctly. This allows for the `LIST_REMOVE` and `LIST_INSERT_HEAD` macros to be defined properly and set the fields previous pointers as well when updating the list. This is needed to enable the use of the macros for list manipulations. Found while implementing file sources for Windows.
1 parent a5f5a92 commit e9335dd

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/shims/generic_sys_queue.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107

108108
#define LIST_ENTRY(type) struct { \
109109
struct type *le_next; \
110-
struct type *le_prev; \
110+
struct type **le_prev; \
111111
}
112112

113113
#define LIST_EMPTY(head) ((head)->lh_first == NULL)
@@ -133,13 +133,14 @@
133133
#define LIST_REMOVE(elm, field) do { \
134134
if (LIST_NEXT((elm), field) != NULL) \
135135
LIST_NEXT((elm), field)->field.le_prev = (elm)->field.le_prev; \
136+
*(elm)->field.le_prev = LIST_NEXT((elm), field); \
136137
} while (0)
137138

138139
#define LIST_INSERT_HEAD(head, elm, field) do { \
139140
if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \
140-
LIST_FIRST((head))->field.le_prev = LIST_NEXT((elm), field); \
141+
LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field); \
141142
LIST_FIRST((head)) = (elm); \
142-
(elm)->field.le_prev = LIST_FIRST((head)); \
143+
(elm)->field.le_prev = &LIST_FIRST((head)); \
143144
} while (0)
144145

145146
#endif // __DISPATCH_SHIMS_SYS_QUEUE__

0 commit comments

Comments
 (0)