Skip to content

Commit de35289

Browse files
committed
Documentation and comment cleanups.
1 parent ac4a66f commit de35289

File tree

22 files changed

+80
-51
lines changed

22 files changed

+80
-51
lines changed

src/backend/libc/c.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub(crate) const PROC_SUPER_MAGIC: u32 = 0x0000_9fa0;
1212
#[cfg(all(linux_kernel, target_env = "musl"))]
1313
pub(crate) const NFS_SUPER_MAGIC: u32 = 0x0000_6969;
1414

15-
// Submitted upstream in https://github.com/rust-lang/libc/pull/3272.
15+
// Submitted upstream in <https://github.com/rust-lang/libc/pull/3272>.
1616
#[cfg(all(linux_kernel, feature = "net"))]
1717
pub(crate) const IPPROTO_ETHERNET: c_int = linux_raw_sys::net::IPPROTO_ETHERNET as _;
1818

src/backend/libc/fs/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ impl From<RawMode> for Mode {
172172
}
173173

174174
impl From<Mode> for RawMode {
175-
/// Support conversions from `Mode to raw mode values.
175+
/// Support conversions from `Mode` to raw mode values.
176176
///
177177
/// ```
178178
/// use rustix::fs::{Mode, RawMode};

src/backend/libc/net/read_sockaddr.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//! The BSD sockets API requires us to read the `ss_family` field before
2+
//! we can interpret the rest of a `sockaddr` produced by the kernel.
3+
14
#[cfg(unix)]
25
use super::addr::SocketAddrUnix;
36
use super::ext::{in6_addr_s6_addr, in_addr_s_addr, sockaddr_in6_sin6_scope_id};
@@ -44,6 +47,11 @@ pub(crate) unsafe fn initialize_family_to_unspec(storage: *mut c::sockaddr_stora
4447
(*storage.cast::<sockaddr_header>()).ss_family = c::AF_UNSPEC as _;
4548
}
4649

50+
/// Read a socket address encoded in a platform-specific format.
51+
///
52+
/// # Safety
53+
///
54+
/// `storage` must point to valid socket address storage.
4755
pub(crate) unsafe fn read_sockaddr(
4856
storage: *const c::sockaddr_storage,
4957
len: usize,

src/backend/linux_raw/param/libc_auxv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use core::ptr::null;
1515
use core::slice;
1616

1717
// `getauxval` wasn't supported in glibc until 2.16. Also this lets us use
18-
// `*mut` as the retrn type to preserve strict provenance.
18+
// `*mut` as the return type to preserve strict provenance.
1919
#[cfg(not(feature = "runtime"))]
2020
weak!(fn getauxval(c::c_ulong) -> *mut c::c_void);
2121

src/check_types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ macro_rules! check_type {
1717
}
1818

1919
/// The same as `check_type`, but for unions and anonymous structs we've
20-
/// renamed to avoid having types like "bindgen_ty_1" in the API.
20+
/// renamed to avoid having types like `bindgen_ty_1` in the API.
2121
macro_rules! check_renamed_type {
2222
($to:ident, $from:ident) => {
2323
assert_eq!(
@@ -48,7 +48,7 @@ macro_rules! check_struct_field {
4848
}
4949

5050
/// The same as `check_struct_field`, but for unions and anonymous structs
51-
/// we've renamed to avoid having types like "bindgen_ty_1" in the API.
51+
/// we've renamed to avoid having types like `bindgen_ty_1` in the API.
5252
macro_rules! check_struct_renamed_field {
5353
($struct:ident, $to:ident, $from:ident) => {
5454
assert_eq!(

src/event/kqueue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ pub enum EventFilter {
226226
}
227227

228228
bitflags::bitflags! {
229-
/// The flags for a `kqueue` event.
229+
/// The flags for a `kqueue` event specifying actions to perform.
230230
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
231231
pub struct EventFlags: u16 {
232232
/// Add the event to the `kqueue`.

src/fs/at.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,20 +99,26 @@ fn _readlinkat(dirfd: BorrowedFd<'_>, path: &CStr, mut buffer: Vec<u8>) -> io::R
9999
}
100100

101101
// SAFETY:
102-
// - "readlink places the contents of the symbolic link pathname in the buffer buf"
103-
// - POSIX definition 3.271 Pathname (https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_271
104-
// "A string that is used to identify a file."
105-
// POSIX definition 3.375: String (https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_375)
106-
// "A contiguous sequence of bytes terminated by and including the first null byte."
102+
// - "readlink places the contents of the symbolic link pathname in the buffer
103+
// buf"
104+
// - [POSIX definition 3.271: Pathname]: "A string that is used to identify a
105+
// file."
106+
// - [POSIX definition 3.375: String]: "A contiguous sequence of bytes
107+
// terminated by and including the first null byte."
107108
// - "readlink does not append a terminating null byte to buf."
108109
//
109110
// Thus, there will be no NUL bytes in the string.
111+
//
112+
// [POSIX definition 3.271: Pathname]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_271
113+
// [POSIX definition 3.375: String]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_375
110114
unsafe {
111115
return Ok(CString::from_vec_unchecked(buffer));
112116
}
113117
}
114118

115-
buffer.reserve(buffer.capacity() + 1); // use `Vec` reallocation strategy to grow capacity exponentially
119+
buffer.reserve(buffer.capacity() + 1); // use `Vec` reallocation
120+
// strategy to grow capacity
121+
// exponentially
116122
}
117123
}
118124

src/fs/cwd.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ use backend::fd::{BorrowedFd, RawFd};
2525
// SAFETY: `AT_FDCWD` is a reserved value that is never dynamically
2626
// allocated, so it'll remain valid for the duration of `'static`.
2727
#[doc(alias = "AT_FDCWD")]
28-
#[cfg(not(target_os = "haiku"))] // Haiku needs https://github.com/rust-lang/rust/pull/112371
28+
#[cfg(not(target_os = "haiku"))] // Haiku needs <https://github.com/rust-lang/rust/pull/112371>
2929
pub const CWD: BorrowedFd<'static> =
3030
unsafe { BorrowedFd::<'static>::borrow_raw(c::AT_FDCWD as RawFd) };
3131

3232
/// Return the value of [`CWD`].
3333
#[deprecated(note = "Use `CWD` in place of `cwd()`.")]
34-
#[cfg(not(target_os = "haiku"))] // Haiku needs https://github.com/rust-lang/rust/pull/112371
34+
#[cfg(not(target_os = "haiku"))] // Haiku needs <https://github.com/rust-lang/rust/pull/112371>
3535
pub const fn cwd() -> BorrowedFd<'static> {
3636
let at_fdcwd = c::AT_FDCWD as RawFd;
3737

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@
120120
#![allow(clippy::unnecessary_cast)]
121121
// It is common in linux and libc APIs for types to vary between platforms.
122122
#![allow(clippy::useless_conversion)]
123-
// Redox and WASI have enough differences that it isn't worth
124-
// precisely conditionallizing all the `use`s for them.
123+
// Redox and WASI have enough differences that it isn't worth precisely
124+
// conditionalizing all the `use`s for them.
125125
#![cfg_attr(any(target_os = "redox", target_os = "wasi"), allow(unused_imports))]
126126

127127
#[cfg(not(feature = "rustc-dep-of-std"))]

src/net/send_recv/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! `recv` and `send`, and variants.
1+
//! `recv`, `send`, and variants.
22
33
#[cfg(unix)]
44
use crate::net::SocketAddrUnix;

0 commit comments

Comments
 (0)