Skip to content

Commit 88a53f2

Browse files
authored
Miscellaneous comment cleanups (#756)
Clean up a TODO comment, say "undefined behavior" instead of "UB", and other miscellaneous tidyings.
1 parent 7a47af8 commit 88a53f2

File tree

6 files changed

+10
-12
lines changed

6 files changed

+10
-12
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ alloc = { version = "1.0.0", optional = true, package = "rustc-std-workspace-all
2525
compiler_builtins = { version = '0.1.49', optional = true }
2626

2727
# The procfs feature needs once_cell.
28+
# With Rust 1.70.0, we can switch to `core::cell::OnceCell`.
2829
[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies]
2930
once_cell = { version = "1.5.2", optional = true }
3031

src/backend/linux_raw/io/syscalls.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,7 @@ pub(crate) fn is_read_write(fd: BorrowedFd<'_>) -> io::Result<(bool, bool)> {
337337
// the write side is shut down.
338338
#[allow(unreachable_patterns)] // `EAGAIN` equals `EWOULDBLOCK`
339339
match crate::backend::net::syscalls::send(fd, &[], SendFlags::DONTWAIT) {
340-
// TODO or-patterns when we don't need 1.51
341-
Err(io::Errno::AGAIN) => (),
342-
Err(io::Errno::WOULDBLOCK) => (),
343-
Err(io::Errno::NOTSOCK) => (),
340+
Err(io::Errno::AGAIN | io::Errno::WOULDBLOCK | io::Errno::NOTSOCK) => (),
344341
Err(io::Errno::PIPE) => write = false,
345342
Err(err) => return Err(err),
346343
Ok(_) => (),

src/backend/linux_raw/vdso_wrappers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub(crate) fn clock_gettime(which_clock: ClockId) -> __kernel_timespec {
4848
// The `ClockId` enum only contains clocks which never fail. It may be
4949
// tempting to change this to `debug_assert_eq`, however they can still
5050
// fail on uncommon kernel configs, so we leave this in place to ensure
51-
// that we don't execute UB if they ever do fail.
51+
// that we don't execute undefined behavior if they ever do fail.
5252
assert_eq!(r0, 0);
5353
result.assume_init()
5454
}

src/io/errno.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! The `Errno` type, which is a minimal wrapper around an error code.
22
//!
3-
//! We define the error constants as individual `const`s instead of an
4-
//! enum because we may not know about all of the host's error values
5-
//! and we don't want unrecognized values to create UB.
3+
//! We define the error constants as individual `const`s instead of an enum
4+
//! because we may not know about all of the host's error values and we don't
5+
//! want unrecognized values to create undefined behavior.
66
77
use crate::backend;
88
use core::{fmt, result};

src/termios/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pub struct Termios {
7272
}
7373

7474
impl Termios {
75-
/// `cfmakeraw(self)`—Set a `Termios` value to the settings for "raw" mode.
75+
/// `cfmakeraw(self)`—Set a `Termios` value to the settings for raw mode.
7676
///
7777
/// In raw mode, input is available a byte at a time, echoing is disabled,
7878
/// and special terminal input and output codes are disabled.
@@ -568,7 +568,7 @@ bitflags! {
568568
}
569569

570570
bitflags! {
571-
/// Flags controlling "local" terminal modes.
571+
/// Flags controlling local terminal modes.
572572
#[repr(transparent)]
573573
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
574574
pub struct LocalModes: c::tcflag_t {

src/thread/id.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub fn gettid() -> Pid {
2121
///
2222
/// # Warning
2323
///
24-
/// This is not the setxid you are looking for... POSIX requires xids to be
24+
/// This is not the setxid you are looking for POSIX requires xids to be
2525
/// process granular, but on Linux they are per-thread. Thus, this call only
2626
/// changes the xid for the current *thread*, not the entire process even
2727
/// though that is in violation of the POSIX standard.
@@ -46,7 +46,7 @@ pub fn set_thread_uid(uid: Uid) -> io::Result<()> {
4646
///
4747
/// # Warning
4848
///
49-
/// This is not the setresxid you are looking for... POSIX requires xids to be
49+
/// This is not the setresxid you are looking for POSIX requires xids to be
5050
/// process granular, but on Linux they are per-thread. Thus, this call only
5151
/// changes the xid for the current *thread*, not the entire process even
5252
/// though that is in violation of the POSIX standard.

0 commit comments

Comments
 (0)