rust: print: document safety of printing functions
PATCH 1/1 rust: print: document safety of printing functions
Signed-off-by Mohamed Osama <[email protected]>
--- rust/kernel/print.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
rust/kernel/print.rs +4 -2
@@ -29,7 +29,8 @@use fmt::Write ;// SAFETY: The C contract guarantees that `buf` is valid if it's less than `end`. let mut w =unsafe {RawFormatter ::from_ptrs (buf.cast (), end.cast ()) }; -// SAFETY: TODO. +// SAFETY: `ptr` is provided by the `%pA` formatting path and points to the +// `fmt::Arguments` passed to `_printk`. let _ = w.write_fmt (unsafe { *ptr.cast ::<fmt::Arguments <'_>>() }); w.pos ().cast () }
@@ -109,7 +110,8 @@ pub unsafe fn call_printk( ) {// `_printk` does not seem to fail in any path. #[cfg( CONFIG_PRINTK )] -// SAFETY: TODO. +// SAFETY: `format_string` is one of the fixed format strings, `module_name` is +// null-terminated, and the `%pA` argument is a pointer to the valid `args`. unsafe { bindings::_printk ( format_string.as_ptr(),
Signature · 1 line
2.43.0
Quoted 2 lines · Mohamed Osama
Signed-off-by Mohamed Osama <[email protected]>
Welcome and thanks for the patch!
The kernel requires a commit message.
In addition, please see (and maybe help review!) previous attempts:
https://lore.kernel.org/rust-for-linux/[email protected]/
Finally, the commit message should have the right tags, and Cc all the maintainers and reviewers of the RUST subsystem from the MAINTAINERS file.
Cheers,
Miguel