Skip to content

Commit

Permalink
device: add braces around dev/dev_rw initializer
Browse files Browse the repository at this point in the history
The init_entry struct got modified to add a union with a non const dev
pointer in afc5911. Some old compiler (such as GCC 4) seems to
require a pair of brackets to correctly initialize the field in the
union. Add those brackets to the initializers in device.h and init.h to
maintain compatibility.

Signed-off-by: Fabio Baltieri <[email protected]>
  • Loading branch information
fabiobaltieri committed Nov 29, 2023
1 parent f74f309 commit 153f38a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 4 additions & 1 deletion include/zephyr/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,10 @@ static inline bool z_impl_device_is_ready(const struct device *dev)
Z_INIT_ENTRY_NAME(DEVICE_NAME_GET(dev_id)) = { \
.init_fn = {COND_CODE_1(Z_DEVICE_IS_MUTABLE(node_id), (.dev_rw), (.dev)) = \
(init_fn_)}, \
.dev = &DEVICE_NAME_GET(dev_id), \
{ \
COND_CODE_1(Z_DEVICE_IS_MUTABLE(node_id), (.dev_rw), (.dev)) = \
&DEVICE_NAME_GET(dev_id), \
}, \
}

/**
Expand Down
5 changes: 1 addition & 4 deletions include/zephyr/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,7 @@ struct init_entry {
#define SYS_INIT_NAMED(name, init_fn_, level, prio) \
static const Z_DECL_ALIGN(struct init_entry) \
Z_INIT_ENTRY_SECTION(level, prio, 0) __used __noasan \
Z_INIT_ENTRY_NAME(name) = { \
.init_fn = {.sys = (init_fn_)}, \
.dev = NULL, \
}
Z_INIT_ENTRY_NAME(name) = {.init_fn = {.sys = (init_fn_)}}

/** @} */

Expand Down

0 comments on commit 153f38a

Please sign in to comment.