docs: add Safety section to unsafe functions

This step was done manually by searching for "unsafe fn" in
the code base and adding corresponding Safety sections.
`clippy::missing_safety_doc` only works for public functions
but none of the corresponding functions is public.

Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
On-behalf-of: SAP philipp.schuster@sap.com
This commit is contained in:
Philipp Schuster
2025-08-26 08:07:04 +02:00
committed by Bo Chen
parent a9d6807522
commit c3a809696a
2 changed files with 19 additions and 0 deletions

View File

@@ -129,6 +129,9 @@ fn ipv6_mask_to_prefix(mask: Ipv6Addr) -> Result<u8> {
}
impl Tap {
/// # Safety
/// The caller should ensure to pass a valid file descriptor and valid
/// arguments for the `ioctl()` syscall.
unsafe fn ioctl_with_mut_ref<F: AsRawFd, T>(fd: &F, req: c_ulong, arg: &mut T) -> Result<()> {
let ret = ioctl_with_mut_ref(fd, req, arg);
if ret < 0 {
@@ -138,6 +141,9 @@ impl Tap {
Ok(())
}
/// # Safety
/// The caller should ensure to pass a valid file descriptor and valid
/// arguments for the `ioctl()` syscall.
unsafe fn ioctl_with_ref<F: AsRawFd, T>(fd: &F, req: c_ulong, arg: &T) -> Result<()> {
let ret = ioctl_with_ref(fd, req, arg);
if ret < 0 {
@@ -147,6 +153,9 @@ impl Tap {
Ok(())
}
/// # Safety
/// The caller should ensure to pass a valid file descriptor and valid
/// arguments for the `ioctl()` syscall.
unsafe fn ioctl_with_val<F: AsRawFd>(fd: &F, req: c_ulong, arg: c_ulong) -> Result<()> {
let ret = ioctl_with_val(fd, req, arg);
if ret < 0 {