Skip to content

Commit 2456019

Browse files
committed
Add ## Safety headings to doc comments
1 parent 3099bc1 commit 2456019

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

src/structures/paging/frame_alloc.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ pub struct UnusedPhysFrame<S: PageSize = Size4KiB>(PhysFrame<S>);
2525
impl<S: PageSize> UnusedPhysFrame<S> {
2626
/// Creates a new UnusedPhysFrame from the given frame.
2727
///
28+
/// ## Safety
29+
///
2830
/// This method is unsafe because the caller must guarantee
2931
/// that the given frame is unused.
3032
pub unsafe fn new(frame: PhysFrame<S>) -> Self {

src/structures/paging/mapper/mapped_page_table.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ impl<'a, P: PhysToVirt> MappedPageTable<'a, P> {
2323
/// Creates a new `MappedPageTable` that uses the passed closure for converting virtual
2424
/// to physical addresses.
2525
///
26+
/// ## Safety
27+
///
2628
/// This function is unsafe because the caller must guarantee that the passed `phys_to_virt`
2729
/// closure is correct. Also, the passed `level_4_table` must point to the level 4 page table
2830
/// of a valid page table hierarchy. Otherwise this function might break memory safety, e.g.

src/structures/paging/mapper/recursive_page_table.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ impl<'a> RecursivePageTable<'a> {
6666

6767
/// Creates a new RecursivePageTable without performing any checks.
6868
///
69+
/// ## Safety
70+
///
6971
/// The `recursive_index` parameter must be the index of the recursively mapped entry.
7072
#[inline]
7173
pub unsafe fn new_unchecked(table: &'a mut PageTable, recursive_index: PageTableIndex) -> Self {

src/structures/port.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
pub trait PortRead {
88
/// Reads a `Self` value from the given port.
99
///
10+
/// ## Safety
11+
///
1012
/// This function is unsafe because the I/O port could have side effects that violate memory
1113
/// safety.
1214
unsafe fn read_from_port(port: u16) -> Self;
@@ -19,6 +21,8 @@ pub trait PortRead {
1921
pub trait PortWrite {
2022
/// Writes a `Self` value to the given port.
2123
///
24+
/// ## Safety
25+
///
2226
/// This function is unsafe because the I/O port could have side effects that violate memory
2327
/// safety.
2428
unsafe fn write_to_port(port: u16, value: Self);

0 commit comments

Comments
 (0)