diff --git a/src/lib.rs b/src/lib.rs index 317d61e6..84f994e9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,9 +15,10 @@ mod sys; pub mod types; use std::marker::PhantomData; +use std::mem::size_of; use std::mem::ManuallyDrop; use std::os::unix::io::{AsRawFd, FromRawFd, RawFd}; -use std::{cmp, io, mem}; +use std::{cmp, io}; #[cfg(feature = "io_safety")] use std::os::unix::io::{AsFd, BorrowedFd}; @@ -135,9 +136,9 @@ impl IoUring { fd: &OwnedFd, p: &sys::io_uring_params, ) -> io::Result<(MemoryMap, squeue::Inner, cqueue::Inner)> { - let sq_len = p.sq_off.array as usize + p.sq_entries as usize * mem::size_of::(); - let cq_len = p.cq_off.cqes as usize + p.cq_entries as usize * mem::size_of::(); - let sqe_len = p.sq_entries as usize * mem::size_of::(); + let sq_len = p.sq_off.array as usize + p.sq_entries as usize * size_of::(); + let cq_len = p.cq_off.cqes as usize + p.cq_entries as usize * size_of::(); + let sqe_len = p.sq_entries as usize * size_of::(); let sqe_mmap = Mmap::new(fd, sys::IORING_OFF_SQES as _, sqe_len)?; if p.features & sys::IORING_FEAT_SINGLE_MMAP != 0 { diff --git a/src/opcode.rs b/src/opcode.rs index 7a9f3d09..ca5c621f 100644 --- a/src/opcode.rs +++ b/src/opcode.rs @@ -4,6 +4,7 @@ use std::convert::TryInto; use std::mem; +use std::mem::size_of; use std::os::unix::io::RawFd; use crate::squeue::Entry; @@ -1106,7 +1107,7 @@ opcode! { sqe.opcode = Self::CODE; sqe.fd = dirfd; sqe.__bindgen_anon_2.addr = pathname as _; - sqe.len = mem::size_of::() as _; + sqe.len = size_of::() as _; sqe.__bindgen_anon_1.off = how as _; if let Some(dest) = file_index { sqe.__bindgen_anon_5.file_index = dest.kernel_index_arg(); diff --git a/src/submit.rs b/src/submit.rs index 97589eba..d7c9c66d 100644 --- a/src/submit.rs +++ b/src/submit.rs @@ -1,6 +1,7 @@ +use std::mem::size_of; use std::os::unix::io::{AsRawFd, RawFd}; use std::sync::atomic; -use std::{io, mem, ptr}; +use std::{io, ptr}; use crate::register::{execute, Probe}; use crate::sys; @@ -91,7 +92,7 @@ impl<'a> Submitter<'a> { let arg = arg .map(|arg| cast_ptr(arg).cast()) .unwrap_or_else(ptr::null); - let size = mem::size_of::(); + let size = size_of::(); sys::io_uring_enter( self.fd.as_raw_fd(), to_submit, @@ -210,7 +211,7 @@ impl<'a> Submitter<'a> { self.fd.as_raw_fd(), sys::IORING_REGISTER_FILES2, cast_ptr::(&rr).cast(), - mem::size_of::() as _, + size_of::() as _, ) .map(drop) } @@ -411,7 +412,7 @@ impl<'a> Submitter<'a> { self.fd.as_raw_fd(), sys::IORING_REGISTER_IOWQ_AFF, cpu_set as *const _ as *const libc::c_void, - mem::size_of::() as u32, + size_of::() as u32, ) .map(drop) } diff --git a/src/types.rs b/src/types.rs index e6179a80..603ebe76 100644 --- a/src/types.rs +++ b/src/types.rs @@ -1,5 +1,7 @@ //! Common Linux types not provided by libc. +use std::mem::size_of; + pub(crate) mod sealed { use super::{Fd, Fixed}; use std::os::unix::io::RawFd; @@ -250,7 +252,7 @@ impl<'prev, 'now> SubmitArgs<'prev, 'now> { #[inline] pub fn sigmask<'new>(mut self, sigmask: &'new libc::sigset_t) -> SubmitArgs<'now, 'new> { self.args.sigmask = cast_ptr(sigmask) as _; - self.args.sigmask_sz = std::mem::size_of::() as _; + self.args.sigmask_sz = size_of::() as _; SubmitArgs { args: self.args, @@ -385,7 +387,7 @@ pub struct RecvMsgOut<'buf> { } impl<'buf> RecvMsgOut<'buf> { - const DATA_START: usize = std::mem::size_of::(); + const DATA_START: usize = size_of::(); /// Parse the data buffered upon completion of a `RecvMsg` multishot operation. ///