Remove redundant return value from write_loop()

This function ought to match the standard write_all().
This commit is contained in:
Johannes Altmanninger 2024-12-29 14:29:52 +01:00
parent 1e384900fa
commit 376bf3a982
2 changed files with 4 additions and 6 deletions

View file

@ -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
/// favor of native rust read/write methods at some point.
///
/// Returns the number of bytes written or an IO error.
pub fn write_loop<Fd: AsRawFd>(fd: &Fd, buf: &[u8]) -> std::io::Result<usize> {
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() {
@ -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

View file

@ -522,13 +522,13 @@ impl EnvUniversal {
}
/// 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 contents = Self::serialize_with_vars(&self.vars);
let res = write_loop(&fd, &contents);
match res.as_ref() {
Ok(_) => {
Ok(()) => {
// 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);
}