Fix doc warnings

This commit is contained in:
jiangjianfeng 2025-12-26 08:16:42 +00:00 committed by Tate, Hongliang Tian
parent dd440c1376
commit bc230b24e1
27 changed files with 54 additions and 35 deletions

View File

@ -8,10 +8,7 @@ use font8x8::UnicodeFonts;
/// A bitmap font.
///
/// Currently it's mainly used to draw texts on the framebuffer console. See
/// [`FramebufferConsole::set_font`].
///
/// [`FramebufferConsole::set_font`]: crate::FramebufferConsole::set_font
/// Currently it's mainly used to draw texts on the framebuffer console.
#[derive(Debug)]
pub struct BitmapFont {
width: usize,

View File

@ -27,7 +27,6 @@ pub enum ConnectError {
///
/// [`register_handler_class`]: crate::register_handler_class
/// [`connect`]: Self::connect
/// [`InputHandler`]: crate::InputHandler
pub trait InputHandlerClass: Send + Sync + Any + Debug {
/// Returns the class name of the handler class.
fn name(&self) -> &str;

View File

@ -34,7 +34,7 @@ use crate::transport::VirtioTransport;
pub const DEVICE_NAME: &str = "Virtio-Input";
/// Select value used for [`device::InputDevice::query_config_select()`].
/// Select value used for `device::InputDevice::select_config`.
#[repr(u8)]
#[derive(Debug, Clone, Copy)]
pub enum InputConfigSelect {

View File

@ -64,15 +64,15 @@ impl<E: Ext> dyn Iface<E> {
}
/// Gets the IPv4 address of the iface, if any.
///
/// FIXME: One iface may have multiple IPv4 addresses.
//
// FIXME: One iface may have multiple IPv4 addresses.
pub fn ipv4_addr(&self) -> Option<Ipv4Address> {
self.common().ipv4_addr()
}
/// Retrieves the prefix length of the interface's IPv4 address.
///
/// Both [`Self::ipv4_addr`] and this method will either return `Some(_)`
/// Both `Self::ipv4_addr` and this method will either return `Some(_)`
/// or both will return `None`.
pub fn prefix_len(&self) -> Option<u8> {
self.common().prefix_len()
@ -90,6 +90,8 @@ impl<E: Ext> dyn Iface<E> {
}
/// Returns a reference to the associated [`ScheduleNextPoll`].
///
/// [`ScheduleNextPoll`]: crate::iface::sched::ScheduleNextPoll
pub fn sched_poll(&self) -> &E::ScheduleNextPoll {
self.common().sched_poll()
}

View File

@ -12,6 +12,10 @@
#![no_std]
#![deny(unsafe_code)]
// Rustdoc does not render methods of public type aliases that reference private types,
// so links pointing to them cannot be resolved.
// See <https://github.com/rust-lang/rust/issues/132952>.
#![expect(rustdoc::private_intra_doc_links)]
pub mod boolean_value;
pub mod device;

View File

@ -2,13 +2,13 @@
// SPDX-License-Identifier: MPL-2.0
//! Provides [`MemObjSlice`] for quick duplication and slicing over memory
//! Provides [`Slice`] for quick duplication and slicing over memory
//! objects, such as [`UFrame`], [`USegment`], [`IoMem`], [`DmaStream`], etc.
//!
//! [`UFrame`]: ostd::mm::UFrame
//! [`USegment`]: ostd::mm::USegment
//! [`IoMem`]: ostd::io::IoMem
//! [`DmaStream`]: ostd::mm::dma::DmaStream
//! [`DmaStream`]: ostd::mm::DmaStream
use alloc::sync::Arc;
use core::{borrow::Borrow, fmt::Debug, ops::Range};

View File

@ -223,6 +223,8 @@ pub struct CgroupNode {
inner: RwMutex<Option<Inner>>,
/// The depth of the node in the cgroupfs [`SysTree`], where the child of
/// the root node has a depth of 1.
///
/// [`SysTree`]: aster_systree::SysTree
depth: usize,
/// Tracks the "populated" status of this node and its direct children.
///

View File

@ -26,6 +26,8 @@ pub(super) fn init() {
///
/// If a subsystem with the same name has already been registered,
/// this function returns an error.
///
/// [`ConfigFs`]: fs::ConfigFs
pub fn register_subsystem(subsystem: Arc<dyn SysBranchNode>) -> Result<()> {
ConfigRootNode::singleton().add_child(subsystem)?;
@ -35,6 +37,8 @@ pub fn register_subsystem(subsystem: Arc<dyn SysBranchNode>) -> Result<()> {
/// Unregisters a subsystem from the root node of [`ConfigFs`] by its name.
///
/// If no subsystem with the given name exists, this function returns an error.
///
/// [`ConfigFs`]: fs::ConfigFs
#[expect(dead_code)]
pub fn unregister_subsystem(name: &str) -> Result<()> {
ConfigRootNode::singleton().remove_child(name)?;

View File

@ -173,6 +173,7 @@ impl WithFileTable for FileTableRefMut<'_> {
///
/// [`RefCell`]: core::cell::RefCell
/// [`ThreadLocal`]: crate::process::posix_thread::ThreadLocal
/// [`RwArc::read`]: ostd::sync::RwArc::read
macro_rules! get_file_fast {
($file_table:expr, $file_desc:expr) => {{
use alloc::borrow::Cow;

View File

@ -309,9 +309,9 @@ pub trait FileIo: Pollable + InodeIo + Send + Sync + 'static {
/// Returns whether the `read()`/`write()` operation should use and advance the offset.
///
/// If [`is_seekable`] succeeds but this method returns `false`, the offset in the `seek()`
/// operation will be ignored. In that case, the `seek()` operation will do nothing but
/// succeed.
/// If [`FileIo::check_seekable`] succeeds but this method returns `false`,
/// the offset in the `seek()` operation will be ignored.
/// In that case, the `seek()` operation will do nothing but succeed.
fn is_offset_aware(&self) -> bool;
// See `FileLike::mappable`.

View File

@ -4,7 +4,7 @@
//!
//! Netlink attributes provide additional information for each [`segment`].
//! Each netlink attribute consists of two components:
//! 1. Header: The attribute header is of type [`CNlAttrHeader`],
//! 1. Header: The attribute header is of type [`CAttrHeader`],
//! which specifies the type and length of the attribute. The attribute
//! type belongs to different classes, which rely on the segment type.
//! 2. Payload: The attribute's payload, which can vary in type.
@ -12,7 +12,7 @@
//! The payload can also include one or multiple other attributes,
//! known as nested attributes.
//!
//! Similar to [`super::segment::NlSegment`], attributes have alignment requirements;
//! Similar to [`super::segment::common::SegmentCommon`], attributes have alignment requirements;
//! both the header and payload must be aligned to [`super::NLMSG_ALIGN`]
//! when being transferred to and from user space.
//!

View File

@ -5,7 +5,7 @@
//!
//! Typically, a segment will consist of three parts:
//!
//! 1. Header: The headers of all segments are of type [`CMegSegHdr`],
//! 1. Header: The headers of all segments are of type [`CMsgSegHdr`],
//! which indicate the type and total length of the segment.
//!
//! 2. Body: The body is the main component of a segment.
@ -19,7 +19,7 @@
//! The total number of attributes is controlled by the `len` field of the header.
//!
//! Note that all headers, bodies, and attributes require
//! their starting address in memory to be aligned to [`super::NLMSG_ALIGN`]
//! their starting address in memory to be aligned to [`NLMSG_ALIGN`]
//! when copying to and from user space.
//! Therefore, necessary padding must be added to ensure alignment.
//!
@ -28,6 +28,8 @@
//! ┌────────┬─────────┬──────┬─────────┬──────┬──────┬──────┐
//! │ Header │ Padding │ Body │ Padding │ Attr │ Attr │ Attr │
//! └────────┴─────────┴──────┴─────────┴──────┴──────┴──────┘
//!
//! [`NLMSG_ALIGN`]: crate::net::socket::netlink::message::NLMSG_ALIGN
pub mod addr;
mod legacy;

View File

@ -156,7 +156,7 @@ pub fn futex_wake_bitset(
/// +---+---+-----------+-----------+
/// 4 4 12 12 <== # of bits
///
/// Reference: https://man7.org/linux/man-pages/man2/futex.2.html.
/// Reference: <https://man7.org/linux/man-pages/man2/futex.2.html>.
struct FutexWakeOpEncode {
op: FutexWakeOp,
/// A flag indicating that the operation will use `1 << oparg`

View File

@ -790,10 +790,10 @@ impl Process {
/// Returns a RCU read guard to the cgroup of the process.
///
/// The returned cgroup is not a stable snapshot. It may be changed by other threads
/// and encounter race conditions. Users can use [`lock_cgroup_membership`] to obtain
/// and encounter race conditions. Users can use [`CgroupMembership`] to obtain
/// a lock to prevent the cgroup from being changed.
///
/// [`lock_cgroup_membership`]: crate::fs::cgroupfs::lock_cgroup_membership
/// [`CgroupMembership`]: crate::fs::cgroupfs::CgroupMembership
pub fn cgroup(&self) -> RcuOptionReadGuard<'_, Arc<CgroupNode>> {
self.cgroup.read()
}

View File

@ -39,7 +39,7 @@ impl TaskSet {
/// Inserts a new task to the task set.
///
/// This method will fail if [`Self::set_exited_group`] or [`Self::set_in_execve`]
/// This method will fail if [`Self::set_exited_group`] or [`Self::start_execve`]
/// has been called before.
pub(super) fn insert(&mut self, task: Arc<Task>) -> core::result::Result<(), Arc<Task>> {
if self.has_exited_group || self.in_execve {

View File

@ -62,6 +62,8 @@ impl RealTimePolicy {
/// - If the time slice is set, the thread is considered to be an RR
/// (round-robin) thread, and will be executed for the time slice, and
/// then it will be put back to the inactive array.
///
/// [`sched_clock`]: super::sched_clock
#[derive(Debug)]
pub struct RealTimeAttr {
prio: AtomicU8,

View File

@ -65,7 +65,7 @@ pub enum ClockId {
/// - Bits 1 and 0 give the type: PROF=0, VIRT=1, SCHED=2, or FD=3.
/// - A clock ID is invalid if bits 2, 1, and 0 are all set.
///
/// Ref: https://github.com/torvalds/linux/blob/master/include/linux/posix-timers_types.h
/// Ref: <https://github.com/torvalds/linux/blob/master/include/linux/posix-timers_types.h>.
pub enum DynamicClockIdInfo {
Pid(u32, DynamicClockType),
Tid(u32, DynamicClockType),

View File

@ -4,7 +4,7 @@
//!
//! The signalfd mechanism allows receiving signals via file descriptor,
//! enabling better integration with event loops.
//! See https://man7.org/linux/man-pages/man2/signalfd.2.html
//! See <https://man7.org/linux/man-pages/man2/signalfd.2.html>.
use core::{
fmt::Display,

View File

@ -17,8 +17,8 @@ use crate::{
};
/// The 'sys_utimensat' system call sets the access and modification times of a file.
/// The times are defined by an array of two timespec structures, where times[0] represents the access time,
/// and times[1] represents the modification time.
/// The times are defined by an array of two timespec structures, where `times[0]` represents the access time,
/// and `times[1]` represents the modification time.
/// The `flags` argument is a bit mask that can include the following values:
/// - `AT_SYMLINK_NOFOLLOW`: If set, the file is not dereferenced if it is a symbolic link.
pub fn sys_utimensat(

View File

@ -16,10 +16,10 @@ use crate::{
vm::{perms::VmPerms, vmar::Vmar},
};
/// Page fault information converted from [`CpuExceptionInfo`].
/// Page fault information converted from [`CpuException`].
///
/// `From<CpuExceptionInfo>` should be implemented for this struct.
/// If `CpuExceptionInfo` is a page fault, `try_from` should return `Ok(PageFaultInfo)`,
/// `From<CpuException>` should be implemented for this struct.
/// If [`CpuException`] is a page fault, `try_from` should return `Ok(PageFaultInfo)`,
/// or `Err(())` (no error information) otherwise.
pub struct PageFaultInfo {
/// The virtual address where a page fault occurred.

View File

@ -28,7 +28,7 @@ pub enum Timeout {
///
/// Setting the timer will trigger a callback function upon expiration of
/// the set time. To enable its periodic functionality, users should set
/// its `interval` field with [`Timer::set_interval`]. By doing this,
/// its `interval` field with [`TimerGuard::set_interval`]. By doing this,
/// the timer will use the interval time to configure a new timing after expiration.
pub struct Timer {
inner: SpinLock<TimerInner>,

View File

@ -13,7 +13,7 @@ use crate::{
/// Socket options for IP socket.
///
/// The raw definitions can be found at:
/// https://elixir.bootlin.com/linux/v6.0.19/source/include/uapi/linux/in.h#L94
/// <https://elixir.bootlin.com/linux/v6.0.19/source/include/uapi/linux/in.h#L94>.
#[repr(i32)]
#[derive(Debug, Clone, Copy, TryFromInt)]
#[expect(non_camel_case_types)]

View File

@ -15,7 +15,7 @@ use crate::{
/// Socket level options.
///
/// The definition is from https://elixir.bootlin.com/linux/v6.0.9/source/include/uapi/asm-generic/socket.h.
/// The definition is from <https://elixir.bootlin.com/linux/v6.0.9/source/include/uapi/asm-generic/socket.h>.
#[repr(i32)]
#[derive(Debug, Clone, Copy, TryFromInt, PartialEq, Eq, PartialOrd, Ord)]
#[expect(non_camel_case_types)]

View File

@ -13,7 +13,7 @@ use crate::{
/// Sock options for tcp socket.
///
/// The raw definition is from https://elixir.bootlin.com/linux/v6.0.9/source/include/uapi/linux/tcp.h#L92
/// The raw definition is from <https://elixir.bootlin.com/linux/v6.0.9/source/include/uapi/linux/tcp.h#L92>.
#[repr(i32)]
#[derive(Debug, Clone, Copy, TryFromInt)]
#[expect(non_camel_case_types)]

View File

@ -11,7 +11,7 @@ use crate::{
};
/// Standard well-defined IP protocols.
/// From https://elixir.bootlin.com/linux/v6.0.9/source/include/uapi/linux/in.h.
/// From <https://elixir.bootlin.com/linux/v6.0.9/source/include/uapi/linux/in.h>.
#[repr(i32)]
#[derive(Debug, Clone, Copy, TryFromInt)]
#[expect(non_camel_case_types)]
@ -45,7 +45,7 @@ pub enum Protocol {
}
/// Socket types.
/// From https://elixir.bootlin.com/linux/v6.0.9/source/include/linux/net.h
/// From <https://elixir.bootlin.com/linux/v6.0.9/source/include/linux/net.h>.
#[repr(i32)]
#[expect(non_camel_case_types)]
#[derive(Debug, Clone, Copy, TryFromInt)]

View File

@ -45,6 +45,8 @@ use crate::{
///
/// This type controls the actual mapping in the [`VmSpace`]. It is a linear
/// type and cannot be [`Drop`]. To remove a mapping, use [`Self::unmap`].
///
/// [`Vmar`]: crate::vm::vmar::Vmar
#[derive(Debug)]
pub struct VmMapping {
/// The size of mapping, in bytes. The map size can even be larger than the
@ -856,6 +858,8 @@ impl Drop for MappedVmo {
/// remove the original mappings before inserting the merged mapping
/// into the [`Vmar`].
/// - Returns `None` otherwise.
///
/// [`Vmar`]: crate::vm::vmar::Vmar
fn try_merge(left: &VmMapping, right: &VmMapping) -> Option<VmMapping> {
let is_adjacent = left.map_end() == right.map_to_addr();
let is_type_equal = left.is_shared == right.is_shared

View File

@ -23,6 +23,8 @@ impl Vmar {
/// mapping does not have to solely map to a whole [`VmMapping`], but it
/// must ensure that all existing ranges have a mapping. Otherwise, this
/// method will return an `Err`.
///
/// [`VmMapping`]: crate::vm::vmar::vm_mapping::VmMapping
pub fn resize_mapping(
&self,
map_addr: Vaddr,