Skip to content

Commit 7f40ac9

Browse files
authored
Miscellaneous documentaion cleanups. (#1421)
- Use `1` instead of `1.0.0` in documentation links in CHANGES.md. - Add more links to platform documentation. - Minor comment cleanups.
1 parent 4bc94ab commit 7f40ac9

File tree

28 files changed

+273
-159
lines changed

28 files changed

+273
-159
lines changed

CHANGES.md

Lines changed: 107 additions & 107 deletions
Large diffs are not rendered by default.

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ cargo test --features=all-apis
1414
```
1515

1616
And, rustix has two backends, linux_raw and libc, and only one is used in
17-
any given build. To test with the libc backend explicitly, additionally
18-
enable the `use-libc` feature:
17+
any given build. To test on Linux with the libc backend explicitly,
18+
additionally enable the `use-libc` feature:
1919

2020
```console
2121
cargo test --features=all-apis,use-libc

src/backend/linux_raw/arch/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ pub(in crate::backend) mod asm;
5656
pub(in crate::backend) use self::asm as choose;
5757

5858
// On 32-bit x86, use vDSO wrappers for all syscalls. We could use the
59-
// architecture syscall instruction (`int 0x80`), but the vDSO kernel_vsyscall
60-
// mechanism is much faster.
59+
// architecture syscall instruction (`int 0x80`), but the vDSO
60+
// `__kernel_vsyscall` mechanism is much faster.
6161
#[cfg(target_arch = "x86")]
6262
pub(in crate::backend) use super::vdso_wrappers::x86_via_vdso as choose;
6363

src/backend/linux_raw/net/sockopt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ fn duration_from_linux_sock_timeval(time: __kernel_sock_timeval) -> Option<Durat
261261
}
262262
}
263263

264-
/// Like `duration_from_linux` but uses Linux's old 32-bit
264+
/// Like `duration_from_linux_sock_timeval` but uses Linux's old 32-bit
265265
/// `__kernel_old_timeval`.
266266
fn duration_from_linux_old_timeval(time: __kernel_old_timeval) -> Option<Duration> {
267267
if time.tv_sec == 0 && time.tv_usec == 0 {
@@ -297,7 +297,7 @@ fn duration_to_linux_sock_timeval(timeout: Option<Duration>) -> io::Result<__ker
297297
})
298298
}
299299

300-
/// Like `duration_to_linux` but uses Linux's old 32-bit
300+
/// Like `duration_to_linux_sock_timeval` but uses Linux's old 32-bit
301301
/// `__kernel_old_timeval`.
302302
fn duration_to_linux_old_timeval(timeout: Option<Duration>) -> io::Result<__kernel_old_timeval> {
303303
Ok(match timeout {

src/backend/linux_raw/param/auxv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ fn maybe_init_auxv() {
282282
/// /proc/self/auxv for kernels that don't support `PR_GET_AUXV`.
283283
#[cold]
284284
fn init_auxv_impl() -> Result<(), ()> {
285-
// 512 AUX elements ought to be enough for anybody…
285+
// 512 bytes of AUX elements ought to be enough for anybody…
286286
let mut buffer = [0_u8; 512];
287287

288288
// If we don't have "alloc", just try to read into our statically-sized

src/buffer.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Utilities to help with buffering.
1+
//! Utilities for functions that return data via buffers.
22
33
#![allow(unsafe_code)]
44

@@ -22,7 +22,7 @@ use core::slice;
2222
///
2323
/// Passing a `&mut [u8]`:
2424
///
25-
/// ```rust
25+
/// ```
2626
/// # use rustix::io::read;
2727
/// # fn example(fd: rustix::fd::BorrowedFd) -> rustix::io::Result<()> {
2828
/// let mut buf = [0_u8; 64];
@@ -34,7 +34,7 @@ use core::slice;
3434
///
3535
/// Passing a `&mut [MaybeUninit<u8>]`:
3636
///
37-
/// ```rust
37+
/// ```
3838
/// # use rustix::io::read;
3939
/// # use std::mem::MaybeUninit;
4040
/// # fn example(fd: rustix::fd::BorrowedFd) -> rustix::io::Result<()> {
@@ -48,7 +48,7 @@ use core::slice;
4848
///
4949
/// Passing a [`SpareCapacity`], via the [`spare_capacity`] helper function:
5050
///
51-
/// ```rust
51+
/// ```
5252
/// # use rustix::io::read;
5353
/// # use rustix::buffer::spare_capacity;
5454
/// # fn example(fd: rustix::fd::BorrowedFd) -> rustix::io::Result<()> {
@@ -293,7 +293,8 @@ mod private {
293293

294294
/// Return a pointer and length for this buffer.
295295
///
296-
/// The length is the number of elements of type `T`, not a number of bytes.
296+
/// The length is the number of elements of type `T`, not a number of
297+
/// bytes.
297298
///
298299
/// It's tempting to have this return `&mut [MaybeUninit<T>]` instead,
299300
/// however that would require this function to be `unsafe`, because
@@ -370,7 +371,10 @@ mod tests {
370371
let mut buf = [0_u8; 64];
371372
let nread = read(&input, &mut buf).unwrap();
372373
assert_eq!(nread, buf.len());
373-
assert_eq!(&buf[..38], b"//! Utilities to help with buffering.\n");
374+
assert_eq!(
375+
&buf[..58],
376+
b"//! Utilities for functions that return data via buffers.\n"
377+
);
374378
input.seek(SeekFrom::End(-1)).unwrap();
375379
let nread = read(&input, &mut buf).unwrap();
376380
assert_eq!(nread, 1);
@@ -393,11 +397,14 @@ mod tests {
393397
let mut buf = [MaybeUninit::<u8>::uninit(); 64];
394398
let (init, uninit) = read(&input, &mut buf).unwrap();
395399
assert_eq!(uninit.len(), 0);
396-
assert_eq!(&init[..38], b"//! Utilities to help with buffering.\n");
400+
assert_eq!(
401+
&init[..58],
402+
b"//! Utilities for functions that return data via buffers.\n"
403+
);
397404
assert_eq!(init.len(), buf.len());
398405
assert_eq!(
399-
unsafe { core::mem::transmute::<&mut [MaybeUninit<u8>], &mut [u8]>(&mut buf[..38]) },
400-
b"//! Utilities to help with buffering.\n"
406+
unsafe { core::mem::transmute::<&mut [MaybeUninit<u8>], &mut [u8]>(&mut buf[..58]) },
407+
b"//! Utilities for functions that return data via buffers.\n"
401408
);
402409
input.seek(SeekFrom::End(-1)).unwrap();
403410
let (init, uninit) = read(&input, &mut buf).unwrap();
@@ -423,7 +430,10 @@ mod tests {
423430
let nread = read(&input, spare_capacity(&mut buf)).unwrap();
424431
assert_eq!(nread, buf.capacity());
425432
assert_eq!(nread, buf.len());
426-
assert_eq!(&buf[..38], b"//! Utilities to help with buffering.\n");
433+
assert_eq!(
434+
&buf[..58],
435+
b"//! Utilities for functions that return data via buffers.\n"
436+
);
427437
buf.clear();
428438
input.seek(SeekFrom::End(-1)).unwrap();
429439
let nread = read(&input, spare_capacity(&mut buf)).unwrap();

src/cstr.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
/// strings, and passing strings to rustix as `CStr`s means that rustix doesn't
66
/// need to copy them into a separate buffer to NUL-terminate them.
77
///
8+
/// In Rust ≥ 1.77, users can use [C-string literals] instead of this macro.
9+
///
810
/// [`CStr`]: crate::ffi::CStr
11+
/// [C-string literals]: https://blog.rust-lang.org/2024/03/21/Rust-1.77.0.html#c-string-literals
912
///
1013
/// # Examples
1114
///

src/event/pause.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use crate::backend;
33
/// `pause()`—Sleep until interrupted by a signal.
44
///
55
/// The POSIX `pause` interface returns an error code, but the only thing
6-
/// `pause` does is sleep until interrupted by a signal, so it always
7-
/// returns the same thing with the same error code, so in rustix, the
6+
/// `pause` does is sleep until interrupted by a signal. If it were exposed in
7+
/// the API here it would always return `Errno::INTR`, so for simplicity the
88
/// return value is omitted.
99
///
1010
/// # References

src/fs/memfd_create.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ use backend::fs::types::MemfdFlags;
44

55
/// `memfd_create(name, flags)`—Create an anonymous file.
66
///
7+
/// For a higher-level API to this functionality, see the [memfd] crate.
8+
///
9+
/// [memfd]: https://crates.io/crates/memfd
10+
///
711
/// # References
812
/// - [Linux]
913
/// - [glibc]

src/fs/xattr.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,16 @@ bitflags! {
2727

2828
/// `getxattr(path, name, value)`—Get extended filesystem attributes.
2929
///
30+
/// For a higher-level API to xattr functionality, see the [xattr] crate.
31+
///
32+
/// [xattr]: https://crates.io/crates/xattr
33+
///
3034
/// # References
3135
/// - [Linux]
36+
/// - [Apple]
3237
///
3338
/// [Linux]: https://man7.org/linux/man-pages/man2/getxattr.2.html
39+
/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getxattr.2.html
3440
#[inline]
3541
pub fn getxattr<P: path::Arg, Name: path::Arg, Buf: Buffer<u8>>(
3642
path: P,
@@ -76,8 +82,10 @@ pub fn lgetxattr<P: path::Arg, Name: path::Arg, Buf: Buffer<u8>>(
7682
///
7783
/// # References
7884
/// - [Linux]
85+
/// - [Apple]
7986
///
8087
/// [Linux]: https://man7.org/linux/man-pages/man2/fgetxattr.2.html
88+
/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/fgetxattr.2.html
8189
#[inline]
8290
pub fn fgetxattr<Fd: AsFd, Name: path::Arg, Buf: Buffer<u8>>(
8391
fd: Fd,
@@ -97,8 +105,10 @@ pub fn fgetxattr<Fd: AsFd, Name: path::Arg, Buf: Buffer<u8>>(
97105
///
98106
/// # References
99107
/// - [Linux]
108+
/// - [Apple]
100109
///
101110
/// [Linux]: https://man7.org/linux/man-pages/man2/setxattr.2.html
111+
/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setxattr.2.html
102112
#[inline]
103113
pub fn setxattr<P: path::Arg, Name: path::Arg>(
104114
path: P,
@@ -136,8 +146,10 @@ pub fn lsetxattr<P: path::Arg, Name: path::Arg>(
136146
///
137147
/// # References
138148
/// - [Linux]
149+
/// - [Apple]
139150
///
140151
/// [Linux]: https://man7.org/linux/man-pages/man2/fsetxattr.2.html
152+
/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/fsetxattr.2.html
141153
#[inline]
142154
pub fn fsetxattr<Fd: AsFd, Name: path::Arg>(
143155
fd: Fd,
@@ -155,6 +167,7 @@ pub fn fsetxattr<Fd: AsFd, Name: path::Arg>(
155167
/// - [Linux]
156168
///
157169
/// [Linux]: https://man7.org/linux/man-pages/man2/listxattr.2.html
170+
/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/listxattr.2.html
158171
#[inline]
159172
pub fn listxattr<P: path::Arg, Buf: Buffer<u8>>(path: P, mut list: Buf) -> io::Result<Buf::Output> {
160173
path.into_with_c_str(|path| {
@@ -190,8 +203,10 @@ pub fn llistxattr<P: path::Arg, Buf: Buffer<u8>>(
190203
///
191204
/// # References
192205
/// - [Linux]
206+
/// - [Apple]
193207
///
194208
/// [Linux]: https://man7.org/linux/man-pages/man2/flistxattr.2.html
209+
/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/flistxattr.2.html
195210
#[inline]
196211
pub fn flistxattr<Fd: AsFd, Buf: Buffer<u8>>(fd: Fd, mut list: Buf) -> io::Result<Buf::Output> {
197212
// SAFETY: `flistxattr` behaves.
@@ -204,8 +219,10 @@ pub fn flistxattr<Fd: AsFd, Buf: Buffer<u8>>(fd: Fd, mut list: Buf) -> io::Resul
204219
///
205220
/// # References
206221
/// - [Linux]
222+
/// - [Apple]
207223
///
208224
/// [Linux]: https://man7.org/linux/man-pages/man2/removexattr.2.html
225+
/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/removexattr.2.html
209226
pub fn removexattr<P: path::Arg, Name: path::Arg>(path: P, name: Name) -> io::Result<()> {
210227
path.into_with_c_str(|path| {
211228
name.into_with_c_str(|name| backend::fs::syscalls::removexattr(path, name))
@@ -230,8 +247,10 @@ pub fn lremovexattr<P: path::Arg, Name: path::Arg>(path: P, name: Name) -> io::R
230247
///
231248
/// # References
232249
/// - [Linux]
250+
/// - [Apple]
233251
///
234252
/// [Linux]: https://man7.org/linux/man-pages/man2/fremovexattr.2.html
253+
/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/fremovexattr.2.html
235254
pub fn fremovexattr<Fd: AsFd, Name: path::Arg>(fd: Fd, name: Name) -> io::Result<()> {
236255
name.into_with_c_str(|name| backend::fs::syscalls::fremovexattr(fd.as_fd(), name))
237256
}

src/io_uring/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2012,7 +2012,7 @@ mod tests {
20122012
assert_eq_align!(io_uring_user_data, u64);
20132013

20142014
// Test that `u64`s and pointers are properly stored in
2015-
// io_uring_user_data`.
2015+
// `io_uring_user_data`.
20162016
unsafe {
20172017
const MAGIC: u64 = !0x0123_4567_89ab_cdef;
20182018
let user_data = io_uring_user_data::from_u64(MAGIC);

src/mm/mmap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ pub fn mlockall(flags: MlockAllFlags) -> io::Result<()> {
411411

412412
/// Unlocks all pages mapped into the address space of the calling process.
413413
///
414-
/// # Warnings
414+
/// # Warning
415415
///
416416
/// This function is aware of all the memory pages in the process, as if it
417417
/// were a debugger. It unlocks all the pages, which could potentially

src/net/send_recv/msg.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ pub enum SendAncillaryMessage<'slice, 'fd> {
143143
impl SendAncillaryMessage<'_, '_> {
144144
/// Get the maximum size of an ancillary message.
145145
///
146-
/// This can be helpful in determining the size of the buffer you allocate.
146+
/// This can be used to determine the size of the buffer to allocate for a
147+
/// [`SendAncillaryBuffer::new`] with one message.
147148
pub const fn size(&self) -> usize {
148149
match self {
149150
Self::ScmRights(slice) => cmsg_space!(ScmRights(slice.len())),

src/param/init.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ use crate::backend;
1414
/// # Safety
1515
///
1616
/// This must be passed a pointer to the original environment variable block
17-
/// set up by the OS at process startup, and it must be called before any
18-
/// other rustix functions are called.
17+
/// set up by the OS at process startup, and it must be called before any other
18+
/// rustix functions are called.
1919
#[inline]
2020
#[doc(hidden)]
2121
pub unsafe fn init(envp: *mut *mut u8) {

src/pid.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl Pid {
8080
}
8181
}
8282

83-
/// Test whether this pid represents the init process (pid 1).
83+
/// Test whether this pid represents the init process ([`Pid::INIT`]).
8484
#[inline]
8585
pub const fn is_init(self) -> bool {
8686
self.0.get() == Self::INIT.0.get()

0 commit comments

Comments
 (0)