Skip to content

Commit c180d5a

Browse files
committed
zephyr: object: Make StaticKernelObject::new unsafe
This function returns initialized memory, and is therefore inherently unsafe. Added some commentary about how it is used safely. Signed-off-by: David Brown <[email protected]>
1 parent 646f255 commit c180d5a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

zephyr/src/object.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ where
161161
/// Construct an empty of these objects, with the zephyr data zero-filled. This is safe in the
162162
/// sense that Zephyr we track the initialization, they start in the uninitialized state, and
163163
/// the zero value of the initialize atomic indicates that it is uninitialized.
164-
pub const fn new() -> StaticKernelObject<T> {
164+
pub const unsafe fn new() -> StaticKernelObject<T> {
165165
StaticKernelObject {
166166
value: unsafe { mem::zeroed() },
167167
init: AtomicUsize::new(KOBJ_UNINITIALIZED),
@@ -240,7 +240,7 @@ macro_rules! _kobj_rule {
240240
($v:vis, $name:ident, StaticMutex) => {
241241
#[link_section = concat!("._k_mutex.static.", stringify!($name), ".", file!(), line!())]
242242
$v static $name: $crate::sys::sync::StaticMutex =
243-
$crate::sys::sync::StaticMutex::new();
243+
unsafe { $crate::sys::sync::StaticMutex::new() };
244244
};
245245

246246
// static NAMES: [StaticMutex; COUNT];
@@ -257,7 +257,7 @@ macro_rules! _kobj_rule {
257257
($v:vis, $name:ident, StaticCondvar) => {
258258
#[link_section = concat!("._k_condvar.static.", stringify!($name), ".", file!(), line!())]
259259
$v static $name: $crate::sys::sync::StaticCondvar =
260-
$crate::sys::sync::StaticCondvar::new();
260+
unsafe { $crate::sys::sync::StaticCondvar::new() };
261261
};
262262

263263
// static NAMES: [StaticCondvar; COUNT];

0 commit comments

Comments
 (0)