proxmox-shared-memory: avoid compiler warnings

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
Dietmar Maurer 2021-11-15 07:28:29 +01:00
parent a1728a72c8
commit 42002bb5c9

View File

@ -1,4 +1,4 @@
use std::path::{Path, PathBuf}; use std::path::Path;
use std::os::unix::io::AsRawFd; use std::os::unix::io::AsRawFd;
use std::mem::MaybeUninit; use std::mem::MaybeUninit;
use std::fs::File; use std::fs::File;
@ -12,7 +12,7 @@ use nix::sys::mman::{MapFlags, ProtFlags};
use nix::sys::stat::Mode; use nix::sys::stat::Mode;
use nix::errno::Errno; use nix::errno::Errno;
use proxmox::tools::fs::{create_path, CreateOptions}; use proxmox::tools::fs::CreateOptions;
use proxmox::tools::mmap::Mmap; use proxmox::tools::mmap::Mmap;
use proxmox::sys::error::SysError; use proxmox::sys::error::SysError;
@ -31,7 +31,7 @@ pub trait Init: Sized {
fn initialize(this: &mut MaybeUninit<Self>); fn initialize(this: &mut MaybeUninit<Self>);
/// Check if the data has the correct format /// Check if the data has the correct format
fn check_type_magic(this: &MaybeUninit<Self>) -> Result<(), Error> { Ok(()) } fn check_type_magic(_this: &MaybeUninit<Self>) -> Result<(), Error> { Ok(()) }
} }
/// Memory mapped shared memory region /// Memory mapped shared memory region
@ -211,6 +211,7 @@ mod test {
use std::sync::Arc; use std::sync::Arc;
use std::sync::atomic::AtomicU64; use std::sync::atomic::AtomicU64;
use std::thread::spawn; use std::thread::spawn;
use proxmox::tools::fs::create_path;
#[derive(Debug)] #[derive(Debug)]
#[repr(C)] #[repr(C)]
@ -233,7 +234,7 @@ mod test {
struct SingleMutexData { struct SingleMutexData {
data: SharedMutex<TestData>, data: SharedMutex<TestData>,
padding: [u8; 4096 - 64 - 8], _padding: [u8; 4096 - 64 - 8],
} }
impl Init for SingleMutexData { impl Init for SingleMutexData {
@ -255,7 +256,7 @@ mod test {
#[test] #[test]
fn test_shared_memory_mutex() -> Result<(), Error> { fn test_shared_memory_mutex() -> Result<(), Error> {
create_path("../target/testdata/", None, None); create_path("../target/testdata/", None, None)?;
let shared: SharedMemory<SingleMutexData> = let shared: SharedMemory<SingleMutexData> =
SharedMemory::open(Path::new("../target/testdata/test1.shm"), CreateOptions::new())?; SharedMemory::open(Path::new("../target/testdata/test1.shm"), CreateOptions::new())?;
@ -264,7 +265,7 @@ mod test {
let start = shared.data().data.lock().count; let start = shared.data().data.lock().count;
let mut threads: Vec<_> = (0..100) let threads: Vec<_> = (0..100)
.map(|_| { .map(|_| {
let shared = shared.clone(); let shared = shared.clone();
spawn(move || { spawn(move || {
@ -318,7 +319,7 @@ mod test {
#[test] #[test]
fn test_shared_memory_multi_mutex() -> Result<(), Error> { fn test_shared_memory_multi_mutex() -> Result<(), Error> {
create_path("../target/testdata/", None, None); create_path("../target/testdata/", None, None)?;
let shared: SharedMemory<MultiMutexData> = let shared: SharedMemory<MultiMutexData> =
SharedMemory::open(Path::new("../target/testdata/test2.shm"), CreateOptions::new())?; SharedMemory::open(Path::new("../target/testdata/test2.shm"), CreateOptions::new())?;
@ -328,7 +329,7 @@ mod test {
let start1 = shared.data().block1.lock().count; let start1 = shared.data().block1.lock().count;
let start2 = shared.data().block2.lock().count; let start2 = shared.data().block2.lock().count;
let mut threads: Vec<_> = (0..100) let threads: Vec<_> = (0..100)
.map(|_| { .map(|_| {
let shared = shared.clone(); let shared = shared.clone();
spawn(move || { spawn(move || {