treewide: avoid address-of-compound-literal idiom in headers
In C99 the construct (T){init-list} is called a compound literal, and is an lvalue. In C++ it is simply a cast expression to non-rvalue type, which is a prvalue. In both languages the expression is a temporary, but in C99 taking its address is well-defined while in C++ it is an error diagnosed as "taking address of temporary". Headers that may be used in C++ application code must avoid invalid expressions. Replace all uses of &(T){init-list} in headers with the functionally equivalent but C++-legal (T[]){{init-list}}. Signed-off-by: Peter A. Bigot <pab@pabigot.com>
This commit is contained in:
parent
0c69c285ec
commit
2802fa4e6d
6 changed files with 32 additions and 32 deletions
|
@ -213,14 +213,14 @@ typedef int (*json_append_bytes_t)(const char *bytes, size_t len,
|
|||
.offset = offsetof(struct_, field_name_), \
|
||||
{ \
|
||||
.array = { \
|
||||
.element_descr = &(struct json_obj_descr) { \
|
||||
.element_descr = (struct json_obj_descr[]) { { \
|
||||
.align_shift = \
|
||||
Z_ALIGN_SHIFT(struct_), \
|
||||
.type = elem_type_, \
|
||||
.offset = \
|
||||
offsetof(struct_, \
|
||||
len_field_), \
|
||||
}, \
|
||||
} }, \
|
||||
.n_elements = (max_len_), \
|
||||
}, \
|
||||
}, \
|
||||
|
@ -275,7 +275,7 @@ typedef int (*json_append_bytes_t)(const char *bytes, size_t len,
|
|||
.offset = offsetof(struct_, field_name_), \
|
||||
{ \
|
||||
.array = { \
|
||||
.element_descr = &(struct json_obj_descr) { \
|
||||
.element_descr = (struct json_obj_descr[]) { { \
|
||||
.align_shift = \
|
||||
Z_ALIGN_SHIFT(struct_), \
|
||||
.type = JSON_TOK_OBJECT_START, \
|
||||
|
@ -289,7 +289,7 @@ typedef int (*json_append_bytes_t)(const char *bytes, size_t len,
|
|||
elem_descr_len_, \
|
||||
}, \
|
||||
}, \
|
||||
}, \
|
||||
} }, \
|
||||
.n_elements = (max_len_), \
|
||||
}, \
|
||||
}, \
|
||||
|
@ -353,7 +353,7 @@ typedef int (*json_append_bytes_t)(const char *bytes, size_t len,
|
|||
.offset = offsetof(struct_, field_name_), \
|
||||
{ \
|
||||
.array = { \
|
||||
.element_descr = &(struct json_obj_descr) { \
|
||||
.element_descr = (struct json_obj_descr[]) { { \
|
||||
.align_shift = \
|
||||
Z_ALIGN_SHIFT(struct_), \
|
||||
.type = JSON_TOK_LIST_START, \
|
||||
|
@ -367,7 +367,7 @@ typedef int (*json_append_bytes_t)(const char *bytes, size_t len,
|
|||
elem_descr_len_, \
|
||||
}, \
|
||||
}, \
|
||||
}, \
|
||||
} }, \
|
||||
.n_elements = (max_len_), \
|
||||
}, \
|
||||
}, \
|
||||
|
@ -464,13 +464,13 @@ typedef int (*json_append_bytes_t)(const char *bytes, size_t len,
|
|||
.offset = offsetof(struct_, struct_field_name_), \
|
||||
{ \
|
||||
.array = { \
|
||||
.element_descr = &(struct json_obj_descr) { \
|
||||
.element_descr = (struct json_obj_descr[]) { { \
|
||||
.align_shift = \
|
||||
Z_ALIGN_SHIFT(struct_), \
|
||||
.type = elem_type_, \
|
||||
.offset = offsetof(struct_, \
|
||||
len_field_), \
|
||||
}, \
|
||||
} }, \
|
||||
.n_elements = (max_len_), \
|
||||
}, \
|
||||
}, \
|
||||
|
@ -534,7 +534,7 @@ typedef int (*json_append_bytes_t)(const char *bytes, size_t len,
|
|||
.offset = offsetof(struct_, struct_field_name_), \
|
||||
{ \
|
||||
.array = { \
|
||||
.element_descr = &(struct json_obj_descr) { \
|
||||
.element_descr = (struct json_obj_descr[]) { { \
|
||||
.align_shift = \
|
||||
Z_ALIGN_SHIFT(struct_), \
|
||||
.type = JSON_TOK_OBJECT_START, \
|
||||
|
@ -548,7 +548,7 @@ typedef int (*json_append_bytes_t)(const char *bytes, size_t len,
|
|||
elem_descr_len_, \
|
||||
}, \
|
||||
}, \
|
||||
}, \
|
||||
} }, \
|
||||
.n_elements = (max_len_), \
|
||||
}, \
|
||||
}, \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue