Skip to content

Commit 7537388

Browse files
gmarullcarlescufi
authored andcommitted
device: move handle size assert close to type definition
This improves code readability. Signed-off-by: Gerard Marull-Paretas <[email protected]>
1 parent 3426050 commit 7537388

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

include/zephyr/device.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ extern "C" {
6262
*/
6363
typedef int16_t device_handle_t;
6464

65+
/*
66+
* The build assert will fail if device_handle_t changes size, which
67+
* means the alignment directives in the linker scripts and in
68+
* `gen_handles.py` must be updated.
69+
*/
70+
BUILD_ASSERT(sizeof(device_handle_t) == 2, "fix the linker scripts");
71+
6572
/** @brief Flag value used in lists of device handles to separate
6673
* distinct groups.
6774
*
@@ -870,12 +877,7 @@ static inline bool z_impl_device_is_ready(const struct device *dev)
870877
* files, which will be retained in subsequent links both wasting
871878
* space and resulting in aggregate size changes relative to pass2
872879
* when all objects will be in the same input section.
873-
*
874-
* The build assert will fail if device_handle_t changes size, which
875-
* means the alignment directives in the linker scripts and in
876-
* `gen_handles.py` must be updated.
877880
*/
878-
BUILD_ASSERT(sizeof(device_handle_t) == 2, "fix the linker scripts");
879881
#define Z_DEVICE_HANDLES_DEFINE(node_id, dev_id, ...) \
880882
extern Z_DEVICE_HANDLES_CONST device_handle_t \
881883
Z_DEVICE_HANDLE_NAME(node_id, dev_id)[]; \

0 commit comments

Comments
 (0)