mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-30 11:21:15 -03:00
Remove redundant return value from write_loop()
This function ought to match the standard write_all().
This commit is contained in:
@@ -1369,9 +1369,7 @@ pub fn valid_func_name(name: &wstr) -> bool {
|
|||||||
|
|
||||||
/// A rusty port of the C++ `write_loop()` function from `common.cpp`. This should be deprecated in
|
/// 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.
|
/// favor of native rust read/write methods at some point.
|
||||||
///
|
pub fn write_loop<Fd: AsRawFd>(fd: &Fd, buf: &[u8]) -> std::io::Result<()> {
|
||||||
/// Returns the number of bytes written or an IO error.
|
|
||||||
pub fn write_loop<Fd: AsRawFd>(fd: &Fd, buf: &[u8]) -> std::io::Result<usize> {
|
|
||||||
let fd = fd.as_raw_fd();
|
let fd = fd.as_raw_fd();
|
||||||
let mut total = 0;
|
let mut total = 0;
|
||||||
while total < buf.len() {
|
while total < buf.len() {
|
||||||
@@ -1387,7 +1385,7 @@ pub fn write_loop<Fd: AsRawFd>(fd: &Fd, buf: &[u8]) -> std::io::Result<usize> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(total)
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A rusty port of the C++ `read_loop()` function from `common.cpp`. This should be deprecated in
|
/// A rusty port of the C++ `read_loop()` function from `common.cpp`. This should be deprecated in
|
||||||
|
|||||||
@@ -522,13 +522,13 @@ fn open_temporary_file(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Writes our state to the fd. path is provided only for error reporting.
|
/// Writes our state to the fd. path is provided only for error reporting.
|
||||||
fn write_to_fd(&mut self, fd: impl AsFd, path: &wstr) -> std::io::Result<usize> {
|
fn write_to_fd(&mut self, fd: impl AsFd, path: &wstr) -> std::io::Result<()> {
|
||||||
let fd = fd.as_fd();
|
let fd = fd.as_fd();
|
||||||
let contents = Self::serialize_with_vars(&self.vars);
|
let contents = Self::serialize_with_vars(&self.vars);
|
||||||
|
|
||||||
let res = write_loop(&fd, &contents);
|
let res = write_loop(&fd, &contents);
|
||||||
match res.as_ref() {
|
match res.as_ref() {
|
||||||
Ok(_) => {
|
Ok(()) => {
|
||||||
// Since we just wrote out this file, it matches our internal state; pretend we read from it.
|
// Since we just wrote out this file, it matches our internal state; pretend we read from it.
|
||||||
self.last_read_file = file_id_for_fd(fd);
|
self.last_read_file = file_id_for_fd(fd);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user