From: Mathieu Desnoyers Date: Wed, 8 Sep 2021 19:30:28 +0000 (-0400) Subject: Fix order of initializers in CDS_LIST_HEAD_INIT X-Git-Tag: v0.14.0~59 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=ce4a1f76adc73cda1ff7d4c98eb54bbd188faadf;p=userspace-rcu.git Fix order of initializers in CDS_LIST_HEAD_INIT When using CDS_LIST_HEAD_INIT in a C++ program, we get (with clang rather than gcc, because the error message is clearer): /home/simark/src/urcu/tests/unit/test_build_cxx.cpp:73:13: error: ISO C++ requires field designators to be specified in declaration order; field 'prev' will be initialized after field 'next' [-Werror,-Wreorder-init-list] .head = CDS_LIST_HEAD_INIT(list.head), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/simark/src/urcu/include/urcu/list.h:49:53: note: expanded from macro 'CDS_LIST_HEAD_INIT' #define CDS_LIST_HEAD_INIT(name) { .prev = &(name), .next = &(name) } ^~~~~~~~~~~~~~~ /home/simark/src/urcu/tests/unit/test_build_cxx.cpp:73:13: note: previous initialization for field 'prev' is here .head = CDS_LIST_HEAD_INIT(list.head), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/simark/src/urcu/include/urcu/list.h:49:44: note: expanded from macro 'CDS_LIST_HEAD_INIT' #define CDS_LIST_HEAD_INIT(name) { .prev = &(name), .next = &(name) } ^~~~~~~ Fix that by swapping the initializers in CDS_LIST_HEAD_INIT. Change-Id: Ib127b9cc128fd64f5b2ae028e093be42ca10f437 Signed-off-by: Simon Marchi Signed-off-by: Mathieu Desnoyers --- diff --git a/include/urcu/list.h b/include/urcu/list.h index f3b8678..8cfbd84 100644 --- a/include/urcu/list.h +++ b/include/urcu/list.h @@ -46,7 +46,7 @@ struct cds_list_head { #define CDS_INIT_LIST_HEAD(ptr) \ (ptr)->next = (ptr)->prev = (ptr) -#define CDS_LIST_HEAD_INIT(name) { .prev = &(name), .next = &(name) } +#define CDS_LIST_HEAD_INIT(name) { .next = &(name), .prev = &(name) } /* Add new element at the head of the list. */ static inline