mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-04 15:51:15 -03:00
cleanup: don't export write_loop twice
Exporting it as both `safe_write_loop` and `write_loop` is redundant and causes inconsistencies. Remove the `pub use` and use `write_loop` for the function name. It is shorter, and in Rust the default assumption is that code is safe unless otherwise indicated, so there is no need to be explicit about it. Part of #12625
This commit is contained in:
committed by
Johannes Altmanninger
parent
9c819c020e
commit
dc63b7bb20
@@ -213,7 +213,7 @@ fn read_to_end_interruptible(&mut self, buf: &mut Vec<u8>) -> std::io::Result<()
|
||||
|
||||
/// A rusty port of the C++ `write_loop()` function from `common.cpp`. This should be deprecated in
|
||||
/// favor of native rust read/write methods at some point.
|
||||
pub fn safe_write_loop<Fd: AsRawFd>(fd: &Fd, buf: &[u8]) -> std::io::Result<()> {
|
||||
pub fn write_loop<Fd: AsRawFd>(fd: &Fd, buf: &[u8]) -> std::io::Result<()> {
|
||||
let fd = fd.as_raw_fd();
|
||||
let mut total = 0;
|
||||
while total < buf.len() {
|
||||
@@ -232,8 +232,6 @@ pub fn safe_write_loop<Fd: AsRawFd>(fd: &Fd, buf: &[u8]) -> std::io::Result<()>
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub use safe_write_loop as write_loop;
|
||||
|
||||
pub const fn help_section_exists(section: &str) -> bool {
|
||||
let haystack = include_str!("../../../share/help_sections");
|
||||
let needle = section;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
};
|
||||
use crate::threads::assert_is_main_thread;
|
||||
use crate::wutil::{perror_nix, wcstoi};
|
||||
use fish_common::{safe_write_loop, write_loop};
|
||||
use fish_common::write_loop;
|
||||
use fish_util::perror;
|
||||
use libc::{EINVAL, ENOTTY, EPERM, STDIN_FILENO, WNOHANG};
|
||||
use nix::sys::termios::tcgetattr;
|
||||
@@ -336,7 +336,7 @@ pub fn safe_deactivate_tty_protocols() {
|
||||
|
||||
let commands = protocols.safe_get_commands(false);
|
||||
// Safety: just writing data to stdout.
|
||||
let _ = safe_write_loop(&libc::STDOUT_FILENO, commands);
|
||||
let _ = write_loop(&libc::STDOUT_FILENO, commands);
|
||||
TTY_PROTOCOLS_ACTIVE.store(false, Ordering::Release);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user