Skip to content

Commit

Permalink
apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: bjorn3 <[email protected]>
  • Loading branch information
squell and bjorn3 committed Oct 9, 2024
1 parent ee68956 commit 20994d3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/system/term/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl Pty {
Ok(Self {
path,
leader: PtyLeader {
// SAFETY: `leader` has been set by `openpty`
// SAFETY: `openpty` has set `leader` to an open fd suitable for assuming ownership by `OwnedFd`.
file: unsafe { OwnedFd::from_raw_fd(leader) }.into(),
},
follower: PtyFollower {
Expand Down Expand Up @@ -166,7 +166,7 @@ impl<F: AsRawFd> Terminal for F {
// SAFETY: tcgetpgrp cannot cause UB
cerr(unsafe { libc::tcgetpgrp(self.as_raw_fd()) })
}
/// Set the foreground process group ID associated with this terminalto `pgrp`.
/// Set the foreground process group ID associated with this terminal to `pgrp`.
fn tcsetpgrp(&self, pgrp: ProcessId) -> io::Result<()> {
// SAFETY: tcsetpgrp cannot cause UB
cerr(unsafe { libc::tcsetpgrp(self.as_raw_fd(), pgrp) }).map(|_| ())
Expand All @@ -189,7 +189,7 @@ impl<F: AsRawFd> Terminal for F {
}

// SAFETY: `buf` is a valid and initialized pointer, and its correct length is passed
cerr(unsafe { libc::ttyname_r(self.as_raw_fd(), buf.as_mut_ptr() as _, buf.len()) })?;
cerr(unsafe { libc::ttyname_r(self.as_raw_fd(), buf.as_mut_ptr(), buf.len()) })?;
// SAFETY: `buf` will have been initialized by the `ttyname_r` call, if it succeeded
Ok(unsafe { os_string_from_ptr(buf.as_ptr()) })
}
Expand Down
4 changes: 2 additions & 2 deletions src/system/term/user_term.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const LOCAL_FLAGS: tcflag_t = ISIG

static GOT_SIGTTOU: AtomicBool = AtomicBool::new(false);

/// This is like `tcsetattr` but it only suceeds if we are in the foreground process group.
/// This is like `tcsetattr` but it only succeeds if we are in the foreground process group.
/// # Safety
///
/// The arguments to this function have to be valid arguments to `tcsetattr`.
Expand Down Expand Up @@ -247,7 +247,7 @@ impl UserTerm {
};

// Set terminal to raw mode.
// SAFETY: `term` is a valid, initialized pointer to struct of type `termios`, which
// SAFETY: `term` is a valid, initialized struct of type `termios`, which
// was previously obtained through `tcgetattr`.
unsafe { cfmakeraw(&mut term) };
// Enable terminal signals.
Expand Down

0 comments on commit 20994d3

Please sign in to comment.