mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block_util: Use anonymous case to handle ioctl signature difference
Between musl and glibc there is a difference in the signature of the ioctl libc function. Use an anonymous cast to force the type coversion. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
@@ -3,7 +3,6 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
|
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
|
||||||
|
|
||||||
use libc::{ioctl, S_IFBLK, S_IFMT};
|
use libc::{ioctl, S_IFBLK, S_IFMT};
|
||||||
use std::convert::TryInto;
|
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::os::unix::io::AsRawFd;
|
use std::os::unix::io::AsRawFd;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
@@ -66,7 +65,6 @@ impl DiskTopology {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// libc::ioctl() takes different types on different architectures
|
// libc::ioctl() takes different types on different architectures
|
||||||
#[allow(clippy::useless_conversion)]
|
|
||||||
fn query_block_size(f: &mut File, block_size_type: BlockSize) -> std::io::Result<u64> {
|
fn query_block_size(f: &mut File, block_size_type: BlockSize) -> std::io::Result<u64> {
|
||||||
let mut block_size = 0;
|
let mut block_size = 0;
|
||||||
// SAFETY: FFI call with correct arguments
|
// SAFETY: FFI call with correct arguments
|
||||||
@@ -78,9 +76,7 @@ impl DiskTopology {
|
|||||||
BlockSize::PhysicalBlock => BLKPBSZGET(),
|
BlockSize::PhysicalBlock => BLKPBSZGET(),
|
||||||
BlockSize::MinimumIo => BLKIOMIN(),
|
BlockSize::MinimumIo => BLKIOMIN(),
|
||||||
BlockSize::OptimalIo => BLKIOOPT(),
|
BlockSize::OptimalIo => BLKIOOPT(),
|
||||||
}
|
} as _,
|
||||||
.try_into()
|
|
||||||
.unwrap(),
|
|
||||||
&mut block_size,
|
&mut block_size,
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user