Skip to content

Commit d989d45

Browse files
authored
Miscellaneous cleanups. (#652)
- Wrap some code comments at 79 columns, for consistency with the rest of the codebase. - Remove some redundant `use`s. - Fix some broken doc links.
1 parent ed5f233 commit d989d45

File tree

25 files changed

+73
-72
lines changed

25 files changed

+73
-72
lines changed

src/backend/libc/fs/inotify.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ pub fn inotify_add_watch<P: crate::path::Arg>(
113113
/// by [`inotify_add_watch`] and not previously have been removed.
114114
#[doc(alias = "inotify_rm_watch")]
115115
pub fn inotify_remove_watch(inot: BorrowedFd<'_>, wd: i32) -> io::Result<()> {
116-
// Android's `inotify_rm_watch` takes u32 despite `inotify_add_watch` is i32.
116+
// Android's `inotify_rm_watch` takes `u32` despite that
117+
// `inotify_add_watch` expects a `i32`.
117118
#[cfg(target_os = "android")]
118119
let wd = wd as u32;
119120
// SAFETY: The fd is valid and closing an arbitrary wd is valid.

src/backend/libc/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ pub(crate) mod time;
9393
#[cfg(all(unix, target_env = "gnu"))]
9494
pub(crate) fn if_glibc_is_less_than_2_25() -> bool {
9595
// This is also defined inside `weak_or_syscall!` in
96-
// backend/libc/rand/syscalls.rs, but it's not convenient to re-export the weak
97-
// symbol from that macro, so we duplicate it at a small cost here.
96+
// backend/libc/rand/syscalls.rs, but it's not convenient to re-export the
97+
// weak symbol from that macro, so we duplicate it at a small cost here.
9898
weak! { fn getrandom(*mut c::c_void, c::size_t, c::c_uint) -> c::ssize_t }
9999

100100
// glibc 2.25 has `getrandom`, which is how we satisfy the API contract of

src/backend/libc/net/addr.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,9 @@ impl SocketAddrUnix {
9797
if len != 0 && self.unix.sun_path[0] != b'\0' as c::c_char {
9898
let end = len as usize - offsetof_sun_path();
9999
let bytes = &self.unix.sun_path[..end];
100-
// SAFETY: `from_raw_parts` to convert from `&[c_char]` to `&[u8]`. And
101-
// `from_bytes_with_nul_unchecked` since the string is NUL-terminated.
100+
// SAFETY: `from_raw_parts` to convert from `&[c_char]` to `&[u8]`.
101+
// And `from_bytes_with_nul_unchecked` since the string is
102+
// NUL-terminated.
102103
unsafe {
103104
Some(CStr::from_bytes_with_nul_unchecked(slice::from_raw_parts(
104105
bytes.as_ptr().cast(),

src/backend/libc/process/syscalls.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,8 @@ unsafe fn cvt_waitid_status(status: MaybeUninit<c::siginfo_t>) -> Option<WaitidS
503503
// `si_pid` is supposedly the better way to check that the struct has been
504504
// filled, e.g. the Linux manpage says about the `WNOHANG` case “zero out
505505
// the si_pid field before the call and check for a nonzero value”.
506-
// But e.g. NetBSD/OpenBSD don't have it exposed in the libc crate for now, and
507-
// some platforms don't have it at all. For simplicity, always check
506+
// But e.g. NetBSD/OpenBSD don't have it exposed in the libc crate for now,
507+
// and some platforms don't have it at all. For simplicity, always check
508508
// `si_signo`. We have zero-initialized the whole struct, and all kernels
509509
// should set `SIGCHLD` here.
510510
if status.si_signo == 0 {

src/backend/libc/thread/syscalls.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ pub(crate) fn clock_nanosleep_relative(id: ClockId, request: &Timespec) -> Nanos
5050
let mut remain = MaybeUninit::<LibcTimespec>::uninit();
5151
let flags = 0;
5252

53-
// 32-bit gnu version: libc has `clock_nanosleep` but it is not y2038 safe by
54-
// default.
53+
// 32-bit gnu version: libc has `clock_nanosleep` but it is not y2038 safe
54+
// by default.
5555
#[cfg(all(
5656
any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
5757
target_env = "gnu",
@@ -142,8 +142,8 @@ unsafe fn clock_nanosleep_relative_old(id: ClockId, request: &Timespec) -> Nanos
142142
pub(crate) fn clock_nanosleep_absolute(id: ClockId, request: &Timespec) -> io::Result<()> {
143143
let flags = c::TIMER_ABSTIME;
144144

145-
// 32-bit gnu version: libc has `clock_nanosleep` but it is not y2038 safe by
146-
// default.
145+
// 32-bit gnu version: libc has `clock_nanosleep` but it is not y2038 safe
146+
// by default.
147147
#[cfg(all(
148148
any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
149149
target_env = "gnu",

src/backend/linux_raw/conv.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ impl<'a, Num: ArgNumber> From<Option<&'a CStr>> for ArgReg<'a, Num> {
143143
impl<'a, Num: ArgNumber> From<BorrowedFd<'a>> for ArgReg<'a, Num> {
144144
#[inline]
145145
fn from(fd: BorrowedFd<'a>) -> Self {
146-
// SAFETY: `BorrowedFd` ensures that the file descriptor is valid, and the
147-
// lifetime parameter on the resulting `ArgReg` ensures that the result is
148-
// bounded by the `BorrowedFd`'s lifetime.
146+
// SAFETY: `BorrowedFd` ensures that the file descriptor is valid, and
147+
// the lifetime parameter on the resulting `ArgReg` ensures that the
148+
// result is bounded by the `BorrowedFd`'s lifetime.
149149
unsafe { raw_fd(fd.as_raw_fd()) }
150150
}
151151
}

src/backend/linux_raw/io/errno.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ impl Errno {
6262

6363
/// Convert from a C `errno` value (which is positive) to an `Errno`.
6464
const fn from_errno(raw: u32) -> Self {
65-
// We store error values in negated form, so that we don't have to negate
66-
// them after every syscall.
65+
// We store error values in negated form, so that we don't have to
66+
// negate them after every syscall.
6767
let encoded = raw.wrapping_neg() as u16;
6868

6969
// TODO: Use Range::contains, once that's `const`.

src/backend/linux_raw/net/addr.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ impl SocketAddrUnix {
7474
if len != 0 && self.unix.sun_path[0] != b'\0' as c::c_char {
7575
let end = len as usize - offsetof_sun_path();
7676
let bytes = &self.unix.sun_path[..end];
77-
// SAFETY: `from_raw_parts` to convert from `&[c_char]` to `&[u8]`. And
78-
// `from_bytes_with_nul_unchecked` since the string is NUL-terminated.
77+
// SAFETY: `from_raw_parts` to convert from `&[c_char]` to `&[u8]`.
78+
// And `from_bytes_with_nul_unchecked` since the string is
79+
// NUL-terminated.
7980
unsafe {
8081
Some(CStr::from_bytes_with_nul_unchecked(slice::from_raw_parts(
8182
bytes.as_ptr().cast(),

src/backend/linux_raw/vdso_wrappers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,8 @@ fn init() {
376376
assert!(!ptr.is_null());
377377

378378
// SAFETY: Store the computed function addresses in static storage
379-
// so that we don't need to compute it again (but if we do, it doesn't
380-
// hurt anything).
379+
// so that we don't need to compute it again (but if we do, it
380+
// doesn't hurt anything).
381381
unsafe {
382382
CLOCK_GETTIME.store(ptr.cast(), Relaxed);
383383
}

src/cstr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ macro_rules! cstr {
4040

4141
#[allow(unsafe_code, unused_unsafe)]
4242
{
43-
// Now that we know the string doesn't have embedded NULs, we can call
44-
// `from_bytes_with_nul_unchecked`, which as of this writing is defined
45-
// as `#[inline]` and completely optimizes away.
43+
// Now that we know the string doesn't have embedded NULs, we can
44+
// call `from_bytes_with_nul_unchecked`, which as of this writing
45+
// is defined as `#[inline]` and completely optimizes away.
4646
//
4747
// SAFETY: We have manually checked that the string does not contain
4848
// embedded NULs above, and we append or own NUL terminator here.

0 commit comments

Comments
 (0)