async, sys: replace deprecated io_err_other

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2024-07-26 13:09:20 +02:00
parent ce0b21805c
commit e3a5ff78f4
4 changed files with 9 additions and 14 deletions

View File

@ -12,7 +12,7 @@ use tokio::io::AsyncWrite;
use tokio::sync::mpsc::Sender; use tokio::sync::mpsc::Sender;
use proxmox_io::ByteBuffer; use proxmox_io::ByteBuffer;
use proxmox_lang::{error::io_err_other, io_format_err}; use proxmox_lang::io_format_err;
/// Wrapper around tokio::sync::mpsc::Sender, which implements Write /// Wrapper around tokio::sync::mpsc::Sender, which implements Write
pub struct AsyncChannelWriter { pub struct AsyncChannelWriter {
@ -62,7 +62,7 @@ impl AsyncChannelWriter {
let sender = match self.sender.take() { let sender = match self.sender.take() {
Some(sender) => sender, Some(sender) => sender,
None => return Poll::Ready(Err(io_err_other("no sender"))), None => return Poll::Ready(Err(io_format_err!("no sender"))),
}; };
let data = self.buf.remove_data(self.buf.len()).to_vec(); let data = self.buf.remove_data(self.buf.len()).to_vec();

View File

@ -17,8 +17,6 @@ use std::io;
use nix::errno::Errno; use nix::errno::Errno;
use proxmox_lang::error::io_err_other;
/// This trait should be implemented for error types which can represent system errors. Note that /// This trait should be implemented for error types which can represent system errors. Note that
/// it is discouraged to try to map non-system errors to with this trait, since users of this trait /// it is discouraged to try to map non-system errors to with this trait, since users of this trait
/// assume there to be a relation between the error code and a previous system call. For instance, /// assume there to be a relation between the error code and a previous system call. For instance,
@ -146,7 +144,7 @@ macro_rules! other_error {
#[inline] #[inline]
fn into_io_result(self) -> io::Result<T> { fn into_io_result(self) -> io::Result<T> {
self.map_err($crate::error::io_err_other) self.map_err(::std::io::Error::other)
} }
} }
}; };

View File

@ -11,8 +11,6 @@ use nix::sys::stat::Mode;
use nix::unistd::Pid; use nix::unistd::Pid;
use nix::NixPath; use nix::NixPath;
use proxmox_lang::error::io_err_other;
use crate::error::SysResult; use crate::error::SysResult;
use crate::linux::procfs::{MountInfo, PidStat}; use crate::linux::procfs::{MountInfo, PidStat};
use crate::{c_result, c_try}; use crate::{c_result, c_try};
@ -109,13 +107,13 @@ impl PidFd {
/// Get the `PidStat` structure for this process. (`/proc/PID/stat`) /// Get the `PidStat` structure for this process. (`/proc/PID/stat`)
pub fn get_stat(&self) -> io::Result<PidStat> { pub fn get_stat(&self) -> io::Result<PidStat> {
let data = self.read_file(c"stat")?; let data = self.read_file(c"stat")?;
let data = String::from_utf8(data).map_err(io_err_other)?; let data = String::from_utf8(data).map_err(io::Error::other)?;
PidStat::parse(&data).map_err(io_err_other) PidStat::parse(&data).map_err(io::Error::other)
} }
/// Read this process' `/proc/PID/mountinfo` file. /// Read this process' `/proc/PID/mountinfo` file.
pub fn get_mount_info(&self) -> io::Result<MountInfo> { pub fn get_mount_info(&self) -> io::Result<MountInfo> {
MountInfo::parse(&self.read_file(c"mountinfo")?).map_err(io_err_other) MountInfo::parse(&self.read_file(c"mountinfo")?).map_err(io::Error::other)
} }
/// Attempt to get a `PidFd` from a raw file descriptor. /// Attempt to get a `PidFd` from a raw file descriptor.

View File

@ -6,10 +6,9 @@ use std::num::NonZeroUsize;
use std::os::unix::io::RawFd; use std::os::unix::io::RawFd;
use std::{io, mem}; use std::{io, mem};
use anyhow::format_err;
use nix::sys::mman; use nix::sys::mman;
use proxmox_lang::error::io_err_other; use proxmox_lang::io_format_err;
use crate::error::SysError; use crate::error::SysError;
@ -35,7 +34,7 @@ impl<T> Mmap<T> {
flags: mman::MapFlags, flags: mman::MapFlags,
) -> io::Result<Self> { ) -> io::Result<Self> {
let byte_len = NonZeroUsize::new(count * mem::size_of::<T>()) let byte_len = NonZeroUsize::new(count * mem::size_of::<T>())
.ok_or(io_err_other(format_err!("mapped length must not be zero")))?; .ok_or_else(|| io_format_err!("mapped length must not be zero"))?;
// libc::size_t vs usize // libc::size_t vs usize
#[allow(clippy::useless_conversion)] #[allow(clippy::useless_conversion)]
@ -45,7 +44,7 @@ impl<T> Mmap<T> {
prot, prot,
flags, flags,
fd, fd,
libc::off_t::try_from(ofs).map_err(io_err_other)?, libc::off_t::try_from(ofs).map_err(io::Error::other)?,
) )
.map_err(SysError::into_io_error)?; .map_err(SysError::into_io_error)?;