Skip to content

Commit

Permalink
c-list: avoid comma-operator in conditionals
Browse files Browse the repository at this point in the history
There is a bug in VS-2017 where comma-operators are discarded if the
right hand side evaluates to `false`. This was fixed in VS-2019, but
existing VS-2017 installs have not been fixed.

Avoid the comma-operator and use the new c_list_init() behavior to
create a compound statement.

Signed-off-by: David Rheinsberg <david.rheinsberg@gmail.com>
  • Loading branch information
dvdhrm committed Apr 8, 2021
1 parent 2ea502c commit a0970f1
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/c-list.h
Expand Up @@ -364,7 +364,7 @@ static inline CList *c_list_last(CList *list) {

#define c_list_for_each_safe_unlink(_iter, _safe, _list) \
for (_iter = (_list)->next, _safe = (_iter)->next; \
((*_iter = (CList)C_LIST_INIT(*_iter)), (_iter) != (_list)); \
c_list_init(_iter) != (_list); \
_iter = (_safe), _safe = (_safe)->next)

/* c_list_entry() based iterators */
Expand Down Expand Up @@ -400,8 +400,7 @@ static inline CList *c_list_last(CList *list) {
#define c_list_for_each_entry_safe_unlink(_iter, _safe, _list, _m) \
for (_iter = c_list_entry((_list)->next, __typeof__(*_iter), _m), \
_safe = c_list_entry((_iter)->_m.next, __typeof__(*_iter), _m); \
(((_iter)->_m = (CList)C_LIST_INIT((_iter)->_m)), \
&(_iter)->_m != (_list)); \
c_list_init(&(_iter)->_m) != (_list); \
_iter = (_safe), \
_safe = c_list_entry((_safe)->_m.next, __typeof__(*_iter), _m))

Expand Down

0 comments on commit a0970f1

Please sign in to comment.