Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nightly compiler complaints about size_of #289

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -135,9 +136,9 @@ impl<S: squeue::EntryMarker, C: cqueue::EntryMarker> IoUring<S, C> {
fd: &OwnedFd,
p: &sys::io_uring_params,
) -> io::Result<(MemoryMap, squeue::Inner<S>, cqueue::Inner<C>)> {
let sq_len = p.sq_off.array as usize + p.sq_entries as usize * mem::size_of::<u32>();
let cq_len = p.cq_off.cqes as usize + p.cq_entries as usize * mem::size_of::<C>();
let sqe_len = p.sq_entries as usize * mem::size_of::<S>();
let sq_len = p.sq_off.array as usize + p.sq_entries as usize * size_of::<u32>();
let cq_len = p.cq_off.cqes as usize + p.cq_entries as usize * size_of::<C>();
let sqe_len = p.sq_entries as usize * size_of::<S>();
let sqe_mmap = Mmap::new(fd, sys::IORING_OFF_SQES as _, sqe_len)?;

if p.features & sys::IORING_FEAT_SINGLE_MMAP != 0 {
Expand Down
3 changes: 2 additions & 1 deletion src/opcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1106,7 +1107,7 @@ opcode! {
sqe.opcode = Self::CODE;
sqe.fd = dirfd;
sqe.__bindgen_anon_2.addr = pathname as _;
sqe.len = mem::size_of::<sys::open_how>() as _;
sqe.len = size_of::<sys::open_how>() as _;
sqe.__bindgen_anon_1.off = how as _;
if let Some(dest) = file_index {
sqe.__bindgen_anon_5.file_index = dest.kernel_index_arg();
Expand Down
9 changes: 5 additions & 4 deletions src/submit.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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::<T>();
let size = size_of::<T>();
sys::io_uring_enter(
self.fd.as_raw_fd(),
to_submit,
Expand Down Expand Up @@ -210,7 +211,7 @@ impl<'a> Submitter<'a> {
self.fd.as_raw_fd(),
sys::IORING_REGISTER_FILES2,
cast_ptr::<sys::io_uring_rsrc_register>(&rr).cast(),
mem::size_of::<sys::io_uring_rsrc_register>() as _,
size_of::<sys::io_uring_rsrc_register>() as _,
)
.map(drop)
}
Expand Down Expand Up @@ -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::<libc::cpu_set_t>() as u32,
size_of::<libc::cpu_set_t>() as u32,
)
.map(drop)
}
Expand Down
6 changes: 4 additions & 2 deletions src/types.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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::<libc::sigset_t>() as _;
self.args.sigmask_sz = size_of::<libc::sigset_t>() as _;

SubmitArgs {
args: self.args,
Expand Down Expand Up @@ -385,7 +387,7 @@ pub struct RecvMsgOut<'buf> {
}

impl<'buf> RecvMsgOut<'buf> {
const DATA_START: usize = std::mem::size_of::<sys::io_uring_recvmsg_out>();
const DATA_START: usize = size_of::<sys::io_uring_recvmsg_out>();

/// Parse the data buffered upon completion of a `RecvMsg` multishot operation.
///
Expand Down
Loading