/linux-6.12.1/rust/kernel/alloc/ |
D | allocator.rs | 13 /// # Safety 26 // SAFETY: in krealloc_aligned() 28 // function safety requirement. in krealloc_aligned() 30 // to the function safety requirement) in krealloc_aligned() 36 // SAFETY: `ptr::null_mut()` is null and `layout` has a non-zero size by the function safety in alloc() 48 // SAFETY: in realloc() 50 // overflow `isize` by the function safety requirement. in realloc() 54 // SAFETY: in realloc() 55 // - `ptr` is either null or a pointer allocated by this allocator by the function safety in realloc() 57 // - the size of `layout` is not zero because `new_size` is not zero by the function safety in realloc() [all …]
|
D | box_ext.rs | 32 /// // SAFETY: We just wrote to it. 44 // SAFETY: We just wrote to it. in new() 60 // SAFETY: Memory is being allocated (first arg is null). The only other source of in new_uninit() 61 // safety issues is sleeping on atomic context, which is addressed by klint. Lastly, in new_uninit() 72 // SAFETY: For non-zero-sized types, we allocate above using the global allocator. For in new_uninit() 79 // SAFETY: `ptr` is valid, because it came from `Box::into_raw`. in drop_contents() 85 … // SAFETY: `ptr` is valid for writes, because it came from `Box::into_raw` and it is valid for in drop_contents()
|
/linux-6.12.1/Documentation/translations/zh_CN/rust/ |
D | coding-guidelines.rst | 53 此外,就像文档一样,注释在句子的开头要大写,并以句号结束(即使是单句)。这包括 ``// SAFETY:``, 80 一种特殊的注释是 ``// SAFETY:`` 注释。这些注释必须出现在每个 ``unsafe`` 块之前,它们 85 // SAFETY: `p` is valid by the safety requirements. 88 ``// SAFETY:`` 注释不能与代码文档中的 ``# Safety`` 部分相混淆。 ``# Safety`` 部 90 ``// SAFETY:`` 注释显示了为什么一个(函数)调用者或(特性)实现者实际上尊重了 91 ``# Safety`` 部分或语言参考中的前提条件。 111 /// # Safety 127 // SAFETY: The safety contract must be upheld by the caller. 137 - 不安全的函数必须在 ``# Safety`` 部分记录其安全前提条件。 150 - 任何 ``unsafe`` 的代码块都必须在前面加上一个 ``// SAFETY:`` 的注释,描述里面
|
/linux-6.12.1/rust/kernel/ |
D | list.rs | 43 // SAFETY: This is a container of `ListArc<T, ID>`, and access to the container allows the same 51 // SAFETY: This is a container of `ListArc<T, ID>`, and access to the container allows the same 62 /// # Safety 79 /// # Safety 93 /// # Safety 109 /// # Safety 126 /// # Safety 152 // SAFETY: The only way to access/modify the pointers inside of `ListLinks<ID>` is via holding the 156 // SAFETY: The type is opaque so immutable references to a ListLinks are useless. Therefore, it's 173 /// # Safety [all …]
|
D | task.rs | 30 // SAFETY: Deref + addr-of below create a temporary `TaskRef` that cannot outlive the 83 // SAFETY: By design, the only way to access a `Task` is via the `current` function or via an 89 // SAFETY: It's OK to access `Task` through shared references from other threads because we're 103 /// # Safety 120 // SAFETY: Just an FFI call with no additional safety requirements. in current() 124 // SAFETY: If the current thread is still running, the current task is valid. Given in current() 134 // SAFETY: By the type invariant, we know that `self.0` is a valid task. Valid tasks always in group_leader() 138 // SAFETY: The lifetime of the returned task reference is tied to the lifetime of `self`, in group_leader() 146 // SAFETY: By the type invariant, we know that `self.0` is a valid task. Valid tasks always in pid() 153 // SAFETY: By the type invariant, we know that `self.0` is valid. in signal_pending() [all …]
|
D | types.rs | 38 /// # Safety 46 /// # Safety 59 /// # Safety 61 /// `ptr` must either be null or satisfy the safety requirements for 67 // SAFETY: Since `ptr` is not null here, then `ptr` satisfies the safety requirements in try_from_foreign() 68 // of `from_foreign` given the safety requirements of this function. in try_from_foreign() 82 // SAFETY: The safety requirements for this function ensure that the object is still alive, in borrow() 84 // The safety requirements of `from_foreign` also ensure that the object remains alive for in borrow() 90 // SAFETY: The safety requirements of this function ensure that `ptr` comes from a previous in from_foreign() 100 // SAFETY: We are still treating the box as pinned. in into_foreign() [all …]
|
D | device.rs | 46 /// # Safety 55 // SAFETY: By the safety requirements ptr is valid in get_device() 66 /// # Safety 73 // SAFETY: Guaranteed by the safety requirements of the function. in as_ref() 78 // SAFETY: Instances of `Device` are always reference-counted. 81 // SAFETY: The existence of a shared reference guarantees that the refcount is non-zero. in inc_ref() 86 // SAFETY: The safety requirements guarantee that the refcount is non-zero. in dec_ref() 91 // SAFETY: As by the type invariant `Device` can be sent to any thread. 94 // SAFETY: `Device` can be shared among threads because all immutable methods are protected by the
|
D | workqueue.rs | 155 // SAFETY: Accesses to workqueues used by [`Queue`] are thread-safe. 157 // SAFETY: Accesses to workqueues used by [`Queue`] are thread-safe. 163 /// # Safety 168 // SAFETY: The `Queue` type is `#[repr(transparent)]`, so the pointer cast is valid. The in from_raw() 184 // SAFETY: We only return `false` if the `work_struct` is already in a workqueue. The other in enqueue() 236 // SAFETY: The `func` field is not structurally pinned. in project() 264 /// # Safety 284 /// # Safety 308 /// # Safety 318 /// # Safety [all …]
|
D | rbtree.rs | 177 // SAFETY: An [`RBTree`] allows the same kinds of access to its values that a struct allows to its 181 // SAFETY: An [`RBTree`] allows the same kinds of access to its values that a struct allows to its 203 // SAFETY: by the invariants, all pointers are valid. in iter() 218 // SAFETY: by the invariants, all pointers are valid. in iter_mut() 243 // SAFETY: `self.root` is always a valid root node in cursor_front() 258 // SAFETY: `self.root` is always a valid root node in cursor_back() 328 // SAFETY: `raw_self` is a valid pointer to the `RBTree` (created from `self` above). in raw_entry() 332 // SAFETY: All links fields we create are in a `Node<K, V>`. in raw_entry() 335 // SAFETY: `node` is a non-null node so it is valid by the type invariants. in raw_entry() 337 // SAFETY: `curr` is a non-null node so it is valid by the type invariants. in raw_entry() [all …]
|
D | page.rs | 32 // SAFETY: Pages have no logic that relies on them staying on a given thread, so moving them across 36 // SAFETY: Pages have no logic that relies on them not being accessed concurrently, so accessing 65 // SAFETY: Depending on the value of `gfp_flags`, this call may sleep. Other than that, it in alloc_page() 96 // SAFETY: `page` is valid due to the type invariants on `Page`. in with_page_mapped() 103 // SAFETY: Since this API takes the user code as a closure, it can only be used in a manner in with_page_mapped() 146 // SAFETY: The `off` integer is at most `PAGE_SIZE`, so this pointer offset will in with_pointer_into_page() 160 /// # Safety 167 // SAFETY: If `with_pointer_into_page` calls into this closure, then in read_raw() 182 /// # Safety 189 // SAFETY: If `with_pointer_into_page` calls into this closure, then it has performed a in write_raw() [all …]
|
D | firmware.rs | 46 /// # // SAFETY: *NOT* safe, just for the example to get an `ARef<Device>` instance 62 // SAFETY: `pfw` is a valid pointer to a NULL initialized `bindings::firmware` pointer. in request_internal() 69 // SAFETY: `func` not bailing out with a non-zero error code, guarantees that `fw` is a in request_internal() 91 // SAFETY: `self.as_raw()` is valid by the type invariant. in size() 97 // SAFETY: `self.as_raw()` is valid by the type invariant. Additionally, in data() 106 // SAFETY: `self.as_raw()` is valid by the type invariant. in drop() 111 // SAFETY: `Firmware` only holds a pointer to a C `struct firmware`, which is safe to be used from 115 // SAFETY: `Firmware` only holds a pointer to a C `struct firmware`, references to which are safe to
|
D | init.rs | 155 //! // SAFETY: 185 //! // SAFETY: Since `foo` is initialized, destroying is safe. 651 /// The syntax is identical to [`pin_init!`] and its safety caveats also apply: 688 /// The safety caveats from [`try_pin_init!`] also apply: 790 /// // SAFETY: The field is structurally pinned. 799 // SAFETY: This code is unreachable. 802 // SAFETY: This code is unreachable. 822 /// # Safety 841 /// # Safety 899 // SAFETY: The `__pinned_init` function is implemented such that it [all …]
|
D | str.rs | 32 // SAFETY: `BStr` is transparent to `[u8]`. in from_bytes() 165 // SAFETY: This is one of the invariant of `CStr`. in len_with_nul() 182 /// # Safety 189 // SAFETY: The safety precondition guarantees `ptr` is a valid pointer in from_char_ptr() 192 // SAFETY: Lifetime guaranteed by the safety precondition. in from_char_ptr() 194 // SAFETY: As `len` is returned by `strlen`, `bytes` does not contain interior `NUL`. in from_char_ptr() 219 // SAFETY: We just checked that all properties hold. in from_bytes_with_nul() 226 /// # Safety 232 // SAFETY: Properties of `bytes` guaranteed by the safety precondition. in from_bytes_with_nul_unchecked() 239 /// # Safety [all …]
|
/linux-6.12.1/rust/kernel/list/ |
D | impl_list_item_mod.rs | 15 /// # Safety 26 /// # Safety 35 // SAFETY: The caller promises that the pointer is valid. The implementer promises that the in raw_get_list_links() 49 // SAFETY: The implementation of `raw_get_list_links` only compiles if the field has the 61 // SAFETY: The caller promises that the pointer is not dangling. We know that this 73 /// # Safety 91 // SAFETY: The implementation of `raw_get_list_links` only compiles if the field has the 104 // SAFETY: The caller promises that the pointer is not dangling. 127 // SAFETY: See GUARANTEES comment on each method. 135 // SAFETY: The caller guarantees that `me` points at a valid value of type `Self`. [all …]
|
D | arc.rs | 26 /// safety issues. 39 /// # Safety 46 /// # Safety 54 /// # Safety 101 // SAFETY: This field is structurally pinned as per the above assertion. 105 // SAFETY: The caller promises that there is no `ListArc`. 111 // SAFETY: The caller promises that there is no `ListArc` reference, and also 219 // SAFETY: We have a `UniqueArc`, so there is no `ListArc`. in from() 222 // SAFETY: We just called `on_create_list_arc_from_unique` on an arc without a `ListArc`, in from() 255 // SAFETY: We have a `UniqueArc`, so there is no `ListArc`. in pair_from_pin_unique() [all …]
|
D | arc_field.rs | 21 // SAFETY: If the inner type is thread-safe, then it's also okay for `ListArc` to be thread-safe. 23 // SAFETY: If the inner type is thread-safe, then it's also okay for `ListArc` to be thread-safe. 43 /// # Safety 48 // SAFETY: The caller has shared access to the `ListArc`, so they also have shared access in assert_ref() 55 /// # Safety 61 // SAFETY: The caller has exclusive access to the `ListArc`, so they also have exclusive in assert_mut() 75 // SAFETY: We have a shared reference to the `ListArc`. 87 // SAFETY: We have a mutable reference to the `ListArc`.
|
/linux-6.12.1/rust/kernel/block/mq/ |
D | request.rs | 58 /// # Safety 64 // INVARIANT: By the safety requirements of this function, invariants are upheld. in aref_from_raw() 65 // SAFETY: By the safety requirement of this function, we own a in aref_from_raw() 76 /// # Safety 81 // SAFETY: By type invariant, `self.0` is a valid `struct request` and in start_unchecked() 117 // SAFETY: By type invariant, `this.0` was a valid `struct request`. The in end_ok() 129 /// # Safety 135 // SAFETY: By safety requirements for this function, `this` is a in wrapper_ptr() 139 // SAFETY: By C API contract, wrapper_ptr points to a valid allocation in wrapper_ptr() 147 // SAFETY: By type invariant, `self.0` is a valid allocation. Further, in wrapper_ref() [all …]
|
D | operations.rs | 58 /// # Safety 75 // SAFETY: `bd.rq` is valid as required by the safety requirement for in queue_rq_callback() 82 // SAFETY: in queue_rq_callback() 84 // - By the safety requirements of this function, `request` is a valid in queue_rq_callback() 90 // SAFETY: We have exclusive access and we just set the refcount above. in queue_rq_callback() 95 // SAFETY: `bd` is valid as required by the safety requirement for in queue_rq_callback() 110 /// # Safety 120 /// # Safety 128 /// # Safety 141 /// # Safety [all …]
|
/linux-6.12.1/rust/kernel/sync/ |
D | lock.rs | 21 /// # Safety 43 /// # Safety 55 /// # Safety 63 /// # Safety 70 /// # Safety 75 // SAFETY: The safety requirements ensure that the lock is initialised. in relock() 100 // SAFETY: `Lock` can be transferred across thread boundaries iff the data it protects can. 103 // SAFETY: `Lock` serialises the interior mutability it provides, so it is `Sync` as long as the 113 // SAFETY: `slot` is valid while the closure is called and both `name` and `key` have in new() 125 // SAFETY: The constructor of the type calls `init`, so the existence of the object proves in lock() [all …]
|
D | arc.rs | 144 /// # Safety 150 // SAFETY: The caller guarantees that the pointer is valid. in container_of() 152 // SAFETY: We're computing the layout of a real struct that existed when compiling this in container_of() 163 // SAFETY: The pointer is in-bounds of an allocation both before and after offsetting the in container_of() 168 // SAFETY: The pointer can't be null since you can't have an `ArcInner<T>` value at the null in container_of() 184 // SAFETY: It is safe to send `Arc<T>` to another thread when the underlying `T` is `Sync` because 190 // SAFETY: It is safe to send `&Arc<T>` to another thread when the underlying `T` is `Sync` 202 // SAFETY: There are no safety requirements for this FFI call. in new() 209 // SAFETY: We just created `inner` with a reference count of 1, which is owned by the new in new() 218 /// # Safety [all …]
|
/linux-6.12.1/rust/kernel/net/ |
D | phy.rs | 79 /// # Safety 89 // SAFETY: by the function requirements the pointer is valid and we have unique access for in from_raw() 97 // SAFETY: The struct invariant ensures that we may access in phy_id() 105 // SAFETY: The struct invariant ensures that we may access in state() 130 // SAFETY: The struct invariant ensures that we may access in is_link_up() 142 // SAFETY: The struct invariant ensures that we may access in is_autoneg_enabled() 155 // SAFETY: The struct invariant ensures that we may access in is_autoneg_completed() 164 // SAFETY: The struct invariant ensures that we may access in set_speed() 177 // SAFETY: The struct invariant ensures that we may access in set_duplex() 196 // SAFETY: `phydev` is pointing to a valid object by the type invariant of `Self`. in read_paged() [all …]
|
/linux-6.12.1/rust/kernel/init/ |
D | __internal.rs | 19 /// type, since the closure needs to fulfill the same safety requirement as the 23 // SAFETY: While constructing the `InitClosure`, the user promised that it upholds the 35 // SAFETY: While constructing the `InitClosure`, the user promised that it upholds the 50 /// # Safety 61 /// # Safety 79 /// # Safety 90 /// # Safety 143 // SAFETY: As we are being dropped, we only call this once. And since `self.is_init` is in drop() 166 // SAFETY: We never move out of `this`. in init() 169 // the memory (this is a safety guarantee of `Pin`). in init() [all …]
|
/linux-6.12.1/Documentation/rust/ |
D | coding-guidelines.rst | 58 includes ``// SAFETY:``, ``// TODO:`` and other "tagged" comments, e.g.: 88 One special kind of comments are the ``// SAFETY:`` comments. These must appear 94 // SAFETY: `p` is valid by the safety requirements. 97 ``// SAFETY:`` comments are not to be confused with the ``# Safety`` sections 98 in code documentation. ``# Safety`` sections specify the contract that callers 99 (for functions) or implementors (for traits) need to abide by. ``// SAFETY:`` 101 respects the preconditions stated in a ``# Safety`` section or the language 124 /// # Safety 140 // SAFETY: The safety contract must be upheld by the caller. 151 - Unsafe functions must document their safety preconditions under [all …]
|
/linux-6.12.1/rust/kernel/sync/lock/ |
D | spinlock.rs | 90 // SAFETY: The underlying kernel `spinlock_t` object ensures mutual exclusion. `relock` uses the 101 // SAFETY: The safety requirements ensure that `ptr` is valid for writes, and `name` and in init() 107 // SAFETY: The safety requirements of this function ensure that `ptr` points to valid in lock() 113 // SAFETY: The safety requirements of this function ensure that `ptr` is valid and that the in unlock()
|
D | mutex.rs | 92 // SAFETY: The underlying kernel `struct mutex` object ensures mutual exclusion. 102 // SAFETY: The safety requirements ensure that `ptr` is valid for writes, and `name` and in init() 108 // SAFETY: The safety requirements of this function ensure that `ptr` points to valid in lock() 114 // SAFETY: The safety requirements of this function ensure that `ptr` is valid and that the in unlock()
|